Integer.ValueOf(line,16) converts string value line into an Integer object. In this case radix is 16.

intValue() gets the int value from the Integer object created above.

Furthermore, above two steps are equivalent to Integer.parseInt(line,16).

In order to get more INFO please refer Java API Documentation of Integer class.

Answer from Upul Bandara on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ integer-valueof-method-in-java
Integer valueOf() Method in Java - GeeksforGeeks
January 23, 2026 - 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.
๐ŸŒ
Oracle
docs.oracle.com โ€บ javase โ€บ 8 โ€บ docs โ€บ api โ€บ java โ€บ lang โ€บ Integer.html
Integer (Java Platform SE 8 )
October 20, 2025 - The characters in the string must all be decimal digits, except that the first character may be an an ASCII plus sign '+' ('\u002B'). The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseUnsignedInt(java.lang.String, int) method. Parameters: s - a String containing the unsigned int representation to be parsed ยท Returns: the unsigned integer value represented by the argument in decimal. Throws: NumberFormatException - if the string does not contain a parsable unsigned integer. Since: 1.8 ยท public static Integer valueOf(String s, int radix) throws NumberFormatException ยท
Discussions

Integer.valueOf() and parseint()
Integer.parseInt() returns a primitive. valueOf() returns an Integer object. Call the one that matches the return type you need and avoid autoboxing/unboxing. More on reddit.com
๐ŸŒ r/learnjava
5
2
September 14, 2023
Java valueOf() method, and such
Take a look at the Official Documentation . It tells you exactly what it does. If you don't show code, we cannot magically know what you tried. Post the code and the full error message. More on reddit.com
๐ŸŒ r/learnprogramming
3
0
January 5, 2022
Whats the point of using Integer.valueOf(scanner.nextLine()); ?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
๐ŸŒ r/javahelp
17
10
November 24, 2020
Difference between 'new Integer(value)' and ...
For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you More on forums.oracle.com
๐ŸŒ forums.oracle.com
May 11, 2007
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ java โ€บ lang โ€บ integer_valueof_string.htm
Java - Integer valueOf(String s) method
The Java Integer valueOf(String s) method returns an Integer object holding the value of the specified String s.
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ dotnet โ€บ api โ€บ java.lang.integer.valueof
Integer.ValueOf Method (Java.Lang) | Microsoft Learn
Returns an Integer object holding the value of the specified String. [Android.Runtime.Register("valueOf", "(Ljava/lang/String;)Ljava/lang/Integer;", "")] public static Java.Lang.Integer ValueOf(string s);
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ java-how-to-utilize-the-integer-valueof-method-in-java-414178
How to utilize the Integer.valueOf() method in Java | LabEx
Integer i1 = Integer.valueOf("42"); Integer i2 = Integer.valueOf("42"); System.out.println(i1 == i2); // Output: true ยท In the above example, since both i1 and i2 are assigned the value 42, which is within the cached range, the method returns the same Integer object for both calls, resulting in improved memory usage and performance. LabEx, a leading provider of Java programming resources, strongly recommends using the Integer.valueOf() method as a best practice when working with integer values in your Java applications.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ integer-valueof-vs-integer-parseint-with-examples
Integer.valueOf() vs Integer.parseInt() with Examples - GeeksforGeeks
July 11, 2025 - This method will always cache values in the range -128 to 127, inclusive, and may cache other values outside of this range. Syntax: ... // Java program to illustrate the // java.lang.Integer.valueOf(int a) import java.lang.*; public class Geeks { public static void main(String[] args) { Integer obj = new Integer(10); // Returns an Integer instance // representing the specified int value System.out.println("Output Value = " + obj.valueOf(85)); } }
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java numbers โ€บ difference between parseint() and valueof() in java
Difference Between parseInt() and valueOf() in Java | Baeldung
January 8, 2024 - The second variant of valueOf() accepts an int as a parameter and returns the wrapper class Integer. Also, it generates a compile-time error if any other data type such as float is passed to it.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ java โ€บ lang โ€บ integer_valueof_string_radix.htm
Java - Integer valueOf(String s, int radix) method
The Java Integer valueOf(String s, int radix) method returns an Integer object holding the value extracted from the specified String s when parsed with the radix given by the second argument radix.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnjava โ€บ integer.valueof() and parseint()
r/learnjava on Reddit: Integer.valueOf() and parseint()
September 14, 2023 -

Hello, i have started learning java recently by mooc. But during this course, it uses Integer.valueOf while taking integer inputs, I use same way but whenever i do it intellij suggests me parseint(). And I wonder if it is better to use parseint?

Top answer
1 of 3
9
Integer.parseInt() returns a primitive. valueOf() returns an Integer object. Call the one that matches the return type you need and avoid autoboxing/unboxing.
2 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full - best also formatted as code block You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
๐ŸŒ
Codekru
codekru.com โ€บ home โ€บ integer.valueof() method in java with examples
Integer.valueOf() method in Java with Examples - Codekru
December 4, 2022 - public class Codekru { public static void main(String[] args) { String str = "1234"; Integer i1 = Integer.valueOf(str,37); System.out.println("Integer value representing str: " + i1); } } ... Exception in thread "main" java.lang.NumberFormatException: radix 37 greater than Character.MAX_RADIX at java.base/java.lang.Integer.parseInt(Integer.java:623) at java.base/java.lang.Integer.valueOf(Integer.java:957)
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ java valueof() method, and such
r/learnprogramming on Reddit: Java valueOf() method, and such
January 5, 2022 -

Hello friends, I wanted to ask anyone who knew Java what the deal with the valueOf() method was. You see, I was under the assumption that it set it's output to whatever variable it was being associated with, seems simple enough. I tried to use this to get around not being able to convert integers to Strings and vice versa. However, it still displayed a syntax error that I cannot, and it's really getting on my nerves because I need to convert a string to an integer for a homework assignment and nothing I've tried is working. Thanks for your time, and for reading.

๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2024 โ€บ 06 โ€บ valueof-method-in-java
ValueOf() Method in Java
June 2, 2024 - public class ValueOfExample { public ... System.out.println(intObj1); // Output: 101 System.out.println(intObj2); // Output: 200 } } Converts a primitive double or a String to a Double object. public class ValueOfExample { public static void main(String[] args) { // From double to Double ...
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 605431 โ€บ java โ€บ explain-Integer-valueOf-works
Please explain Integer.valueOf(100,2) how it works?? (Beginning Java forum at Coderanch)
February 20, 2013 - Joel Christophel wrote:The first parameter is a String that is formatted like an int, and the second is the base system being used to produce the value of the String. In the case of "100" and 4, you're saying that you want to get the value of 100 in binary. If you know anything about base systems, ...
๐ŸŒ
Java Tutorial HQ
javatutorialhq.com โ€บ java tutorial โ€บ java.lang โ€บ integer โ€บ valueof(int i) method example
Java Integer valueOf(int i) method example
September 30, 2019 - * Convert int input into Integer object */ public class fIntegerValueOfInt { public static void main(String[] args) { // Ask user input System.out.print("Enter Desired Value:"); // declare the scanner object Scanner scan = new Scanner(System.in); // use scanner to get the value from user console int intValue = scan.nextInt(); // close the scanner object scan.close(); // print the value of Integer object out.println("Integer Value:" + Integer.valueOf(intValue)); } } Running the toOctalString() method example source code of Integer class will give you the following output ... JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.
๐ŸŒ
Blogger
javarevisited.blogspot.com โ€บ 2013 โ€บ 04 โ€บ difference-between-valueof-and-parseint-method-java.html
Difference between valueOf and parseInt method in Java? Example
Another difference between parseInt() and valueOf() method is there return type. valueOf() of java.lang.Integer returns an Integer object, while parseInt() method returns an int primitive.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ integer-valueof-vs-integer-parseint-with-examples
Integer.valueOf() vs Integer.parseInt() with Examples
July 20, 2023 - public class Example3 { public static void main(String[] args) { String s = "42.03"; // converting string into integer int n1 = Integer.parseInt(s); int n2 = Integer.valueOf(s); // printing the result System.out.println("n1 = " + n1 + " , n2 = " + n2); } } Exception in thread "main" java.lang.NumberFormatException: For input string: "42.03" at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) at java.base/java.lang.Integer.parseInt(Integer.java:665) at java.base/java.lang.Integer.parseInt(Integer.java:781) at Example3.main(Example3.java:5)
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ ref_string_valueof.asp
Java String valueOf() Method
The valueOf() method returns the string representation of the specified value. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ยท If you want to report an error, ...
๐ŸŒ
Oracle
forums.oracle.com โ€บ ords โ€บ apexds โ€บ post โ€บ difference-between-new-integer-value-and-integer-valueof-va-3352
Difference between 'new Integer(value)' and ...
May 11, 2007 - Hi, Since being told a few months ago on this forum to use Integer.valueOf(value) over a new Integer, as its more memory efficient I have been doing this. Most often when getting values indexed with ...