Actually, valueOf uses parseInt internally. The difference is parseInt returns an int primitive while valueOf returns an Integer object. Consider from the Integer.class source:

Copypublic static int parseInt(String s) throws NumberFormatException {
    return parseInt(s, 10);
}

public static Integer valueOf(String s, int radix) throws NumberFormatException {
    return Integer.valueOf(parseInt(s, radix));
}

public static Integer valueOf(String s) throws NumberFormatException {
    return Integer.valueOf(parseInt(s, 10));
}

As for parsing with a comma, I'm not familiar with one. I would sanitize them.

Copyint million = Integer.parseInt("1,000,000".replace(",", ""));
Answer from corsiKa on Stack Overflow
🌐
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 ·
🌐
GeeksforGeeks
geeksforgeeks.org › java › integer-valueof-method-in-java
Integer valueOf() Method in Java - GeeksforGeeks
July 2, 2018 - A new or cached Integer object is returned. Value remains unchanged. 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.
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 7 )
The string value of this property ... sign, then the rest of it is parsed as a hexadecimal integer exactly as by the method valueOf(java.lang.String, int) with radix 16....
🌐
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
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.
🌐
Javatpoint
javatpoint.com › java-integer-valueof-method
Java Integer.valueOf() Method - Javatpoint
Java Integer.valueOf() Method - The valueOf() method is a static method that returns the relevant Integer Object holding the value of the argument passed. The argument can be a primitive data type, String, etc. Java's valueOf() function is an essential tool for mapping different data types-such ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › integer-valueof-vs-integer-parseint-with-examples
Integer.valueOf() vs Integer.parseInt() with Examples - GeeksforGeeks
July 11, 2025 - // 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)); } }
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.integer.valueof
Integer.ValueOf Method (Java.Lang) | Microsoft Learn
The first argument is interpreted as representing a signed integer in the radix specified by the second argument, exactly as if the arguments were given to the #parseInt(java.lang.String, int) method. The result is an Integer object that represents the integer value specified by the string. In other words, this method returns an Integer object equal to the value of: <blockquote> Integer.valueOf(Integer.parseInt(s, radix))</blockquote>
Find elsewhere
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › lang › Integer.html
Integer (Java SE 11 & JDK 11 )
January 20, 2026 - Otherwise, the property value is parsed as a decimal integer exactly as by the method valueOf(java.lang.String, int) with radix 10.
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java integer valueof() method
Java Integer valueOf() Method
September 1, 2008 - The Java Integer valueOf(String s) method returns an Integer object holding the value of the specified String s.
🌐
Blogger
javarevisited.blogspot.com › 2013 › 04 › difference-between-valueof-and-parseint-method-java.html
Difference between valueOf and parseInt method in Java? Example
Eclipse · jQuery · Java IO · Java XML · Both valueOf and parseInt methods are used to convert String to Integer in Java, but there is subtle differences between them.
🌐
Puredanger
puredanger.github.io › tech.puredanger.com › 2007 › 02 › 01 › valueof
Why YOU should use Integer.valueOf(int)
It prints the time (in nanoseconds) to get the first Integer, the second Integer, and and the total and average while creating 1000000000 Integers using either new Integer() or Integer.valueOf(). ... > java PerfTest n new Integer first = 34921 ns second = 2514 ns all = 15778328252 ns avg = 15 ns > java PerfTest v valueof first = 729981 ns second = 2514 ns all = 7729155801 ns avg = 7 ns
🌐
Coderanch
coderanch.com › t › 605431 › java › explain-Integer-valueOf-works
Please explain Integer.valueOf(100,2) how it works?? (Beginning Java forum at Coderanch)
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums · this forum made possible by our volunteer staff, including ... ... Hi Guys! I have a silly doubt about Integer class static method valueOf(String s,int radix) ,let me show you the sample code ...
🌐
Tutorialspoint
tutorialspoint.com › home › java › java number valueof method
Java Number ValueOf Method
September 1, 2008 - valueOf(String s) − This returns an Integer object holding the value of the specified string representation. valueOf(String s, int radix) − This returns an Integer object holding the integer value of the specified string representation, ...
🌐
Eclipse
bugs.eclipse.org › bugs › show_bug.cgi
489986 – Replace new Integer() with Integer.valueOf() in org.eclipse.test
Planet Eclipse · Newsletter · Videos · Participate · Report a Bug · Forums · Mailing Lists · Wiki · IRC · How to Contribute · Working Groups · Automotive · Internet of Things · LocationTech · Long-Term Support · PolarSys · Science · OpenMDM · Toggle navigation · Bugzilla – Bug 489986 Replace new Integer() with Integer.valueOf() in org.eclipse.test Last modified: 2017-01-18 11:08:40 EST ·
🌐
Tutorialspoint
tutorialspoint.com › java › lang › integer_valueof_string_radix.htm
Java - Integer valueOf(String s, int radix) method
Then using valueOf() method, we're getting the object of octal equivalent value and printing it. package com.tutorialspoint; public class IntegerDemo { public static void main(String[] args) { String s = "170"; System.out.println("String = " + s); /* returns the Integer object of the given string */ System.out.println("valueOf = " + Integer.valueOf(s,8)); } }
🌐
Studytonight
studytonight.com › java-wrapper-class › java-integer-valueof-string-int-method
Java Integer valueOf(String s, int radix) Method - Studytonight
Java valueOf() method returns the value of Integer object associated with the String in accordance with the integer radix.