valueOf method on custom object

gudii9
gudii9 used Ask the Experts™
on
FlightsDestination.valueOf("price")


i was wondering how valueOf() method there on a custom objet
i thought it is just method on String class
https://study.com/academy/lesson/how-to-convert-int-to-string-in-java-valueof-method.html

does take string as input parameter like below
FlightsDestination.valueOf("price")

or
FlightsDestination.valueOf(price)

or

FlightsDestination.valueOf("400")

or
FlightsDestination.valueOf(400)



please advise
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fernando SotoRetired
Distinguished Expert 2017
Commented:
Hi gudii9;

The title of the web page states, "How to Convert Int to String in Java - ValueOf Method" So to convert from an integer to a string the parameter must be an int/integer and not a string.
I can't see the code you posted mentioned anywhere in the link you provided.

Author

Commented:
FlightsDestination.valueOf(PriceEnum.high)


does it take enum value
says

package com.xyz
public enum PriceEnum{

high,
medium,
low

}

Please advise
It's whatever is the value of the integer associated with the HIGH field of the enum called PriceEnum.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial