![]() |
VOOZH | about |
The Integer.valueOf() method of the java.lang.Integer class is used to convert primitive values or strings into Integer objects. It is commonly preferred over constructors because it supports caching and better performance.
Converts a primitive int value into its corresponding Integer wrapper object.
public static Integer valueOf(int a)
Example 1: valueOf(int) with Positive Number
Output Value = 85
Explanation:
Example 2: valueOf(int) with Negative Number
Output Value = -9185
Explanation:
The java.lang.Integer.valueOf(String str) is an inbuilt method which is used to return an Integer object, holding the value of the specified String str.
public static Integer valueOf(String str)
Example 1: valueOf(String) with Positive Number
Integer Value = 424
Explanation:
Example 2: valueOf(String) with Negative Number
Output Value = -6156
Explanation:
The java.lang.Integer.valueOf(String s, int radix) is an inbuilt method which returns an Integer object, holding the value extracted from the specified String when parsed with the base given by the second argument.
public static Integer valueOf(String str, int radix)
Parameter: The method accepts two parameters:
Return Value : The method returns an Integer object holding the value represented by the string argument in the specified base or radix.
Example 1: valueOf(String, radix)
520 4113 10 1021
Explanation: