The ValueOf () method is used to return the value of the native number object for a given parameter, which can be a native data type, string, and so on.
This method is a static method. The method can receive two parameters one is a string, and the other is the cardinality.
Grammar
The method has the following syntax formats:
Staticinteger valueOf(int i)staticinteger valueOf(String s)staticInteger valueOf(String s,int radix)
Parameters
i --integer of the integer object.
s --the string of the Integer object.
Radix -the cardinality used when parsing the string s, which specifies the number of digits 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 that holds the value of the specified String.
integer valueOf (String s, int radix): Returns an integer object that holds the value extracted from the specified String when parsing with the cardinality provided by the second argument.
Instance
Public Class Test{ Public Static voidMain(StringArgs[]){IntegerX=Integer.ValueOf(9);DoubleC= Double.ValueOf(5);FloatA= Float.ValueOf("80");IntegerB= Integer.ValueOf("444",16); Using 16 binarySystem.Out.println(X); System. Out. println(c); System. Out. println(a); System. Out. println(b); }}< /c10>
Compile the above program, the output result is:
95.080.01092
Java valueOf () function