YouTip LogoYouTip

Number Valueof

# Java valueOf() Method [![Image 3: Java Number Class](#)Java Number Class](#) * * * The valueOf() method is used to return the primitive Number object value of the given parameter. The parameter can be a primitive data type, String, etc. This method is a static method. It can receive two parameters: one is a string, and the other is the radix. ### Syntax This method has the following syntax formats: static Integer valueOf(int i)static Integer valueOf(String s)static Integer valueOf(String s, int radix) ### Parameters * **i** -- The integer for the Integer object. * **s** -- The string for the Integer object. * **radix** -- The radix used when parsing the string s, specifying the number system to use. ### Return Value * **Integer valueOf(int i):** Returns an Integer instance representing the specified int value. * **Integer valueOf(String s):** Returns an Integer object holding the value of the specified String. * **Integer valueOf(String s, int radix):** Returns an Integer object, holding the integer value extracted from the specified String when parsed with the radix provided by the second argument. ### Example ## Example public class Test{ public static void main(String args[]){ Integer x =Integer.valueOf(9); Double c =Double.valueOf(5); Float a =Float.valueOf("80"); Integer b =Integer.valueOf("444",16);// Using Hexadecimal System.out.println(x); System.out.println(c); System.out.println(a); System.out.println(b); } } Compiling the above program, the output result is: 95.080.01092 * * Java Number Class](#)
← Att Img LoadingVue3 Forms β†’