🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 8 )
April 21, 2026 - Decodes a String into an Integer. Accepts decimal, hexadecimal, and octal numbers given by the following grammar: ... + DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java™ Language Specification, except that underscores are not accepted between digits.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › lang › Integer.html
Integer (Java SE 21 & JDK 21)
January 20, 2026 - Decodes a String into an Integer. Accepts decimal, hexadecimal, and octal numbers given by the following grammar: ... + DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java Language Specification, except that underscores are not accepted between digits.
🌐
Java
download.java.net › java › early_access › valhalla › docs › api › java.base › java › lang › Integer.html
Integer (Java SE 23 & JDK 23 [build 1])
Decodes a String into an Integer. Accepts decimal, hexadecimal, and octal numbers given by the following grammar: ... + DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java Language Specification, except that underscores are not accepted between digits.
🌐
CodeGym
codegym.cc › java blog › java classes › java.lang.integer class
Java.lang.Integer Class
February 20, 2025 - A reference data type that "wraps" or turns its primitive little brother in a Java object. Integer is a wrapper class for its primitive bro named int. Integer in English means a whole number.
🌐
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 - Decodes a String into an Integer. Accepts decimal, hexadecimal, and octal numbers given by the following grammar: ... + DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java™ Language Specification, except that underscores are not accepted between digits.
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 7 )
Decodes a String into an Integer. Accepts decimal, hexadecimal, and octal numbers given by the following grammar: ... + DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java™ Language Specification, except that underscores are not accepted between digits.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › int-vs-Integer-java-difference-comparison-primitive-object-types
Integer vs. int: What's the difference?
August 3, 2025 - The key difference between the Java int and Integer types is that an int simply represents a whole number, while an Integer has additional properties and methods.
🌐
Oracle
docs.oracle.com › en › java › javase › 20 › docs › api › java.base › java › lang › Integer.html
Integer (Java SE 20 & JDK 20)
July 10, 2023 - Decodes a String into an Integer. Accepts decimal, hexadecimal, and octal numbers given by the following grammar: ... + DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java Language Specification, except that underscores are not accepted between digits.
Find elsewhere
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › Integer.html
Integer (Java SE 17 & JDK 17)
April 21, 2026 - Decodes a String into an Integer. Accepts decimal, hexadecimal, and octal numbers given by the following grammar: ... + DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java Language Specification, except that underscores are not accepted between digits.
🌐
Oracle
docs.oracle.com › en › java › javase › 24 › docs › api › java.base › java › lang › Integer.html
Integer (Java SE 24 & JDK 24)
July 15, 2025 - Decodes a String into an Integer. Accepts decimal, hexadecimal, and octal numbers given by the following grammar: ... + DecimalNumeral, HexDigits, and OctalDigits are as defined in section 3.10.1 of The Java Language Specification, except that underscores are not accepted between digits.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › java_lang_integer.htm
Java - Integer class
The Java Integer class wraps a value of primitive type int in an object. An object of type Integer contains a single field whose type is int. Following is the declaration for java.lang.Integer class − Following are the fields for java.lang.Integer
Top answer
1 of 11
422

int is a primitive type. Variables of type int store the actual binary value for the integer you want to represent. int.parseInt("1") doesn't make sense because int is not a class and therefore doesn't have any methods.

Integer is a class, no different from any other in the Java language. Variables of type Integer store references to Integer objects, just as with any other reference (object) type. Integer.parseInt("1") is a call to the static method parseInt from class Integer (note that this method actually returns an int and not an Integer).

To be more specific, Integer is a class with a single field of type int. This class is used where you need an int to be treated like any other object, such as in generic types or situations where you need nullability.

Note that every primitive type in Java has an equivalent wrapper class:

  • byte has Byte
  • short has Short
  • int has Integer
  • long has Long
  • boolean has Boolean
  • char has Character
  • float has Float
  • double has Double

Wrapper classes inherit from Object class, and primitive don't. So it can be used in collections with Object reference or with Generics.

Since java 5 we have autoboxing, and the conversion between primitive and wrapper class is done automatically. Beware, however, as this can introduce subtle bugs and performance problems; being explicit about conversions never hurts.

2 of 11
10

An Integer is pretty much just a wrapper for the primitive type int. It allows you to use all the functions of the Integer class to make life a bit easier for you.

If you're new to Java, something you should learn to appreciate is the Java documentation. For example, anything you want to know about the Integer Class is documented in detail.

This is straight out of the documentation for the Integer class:

The Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.

🌐
Oracle
docs.oracle.com › javase › 6 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 6)
Decodes a String into an Integer. Accepts decimal, hexadecimal, and octal numbers given by the following grammar: ... - DecimalNumeral, HexDigits, and OctalDigits are defined in §3.10.1 of the Java Language Specification.
🌐
GitHub
github.com › openjdk › jdk › blob › master › src › java.base › share › classes › java › lang › Integer.java
jdk/src/java.base/share/classes/java/lang/Integer.java at master · openjdk/jdk
import static java.lang.String.COMPACT_STRINGS; · /** * The {@code Integer} class is the {@linkplain · * java.lang##wrapperClass wrapper class} for values of the primitive · * type {@code int}. An object of type {@code Integer} contains a · * single field whose type is {@code int}. * * <p>In addition, this class provides several methods for converting ·
Author   openjdk
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.integer
Integer Class (Java.Lang) | Microsoft Learn
The Integer class wraps a value of the primitive type int in an object. [Android.Runtime.Register("java/lang/Integer", DoNotGenerateAcw=true)] public sealed class Integer : Java.Lang.Number, IConvertible, IDisposable, Java.Interop.IJavaPeerable, ...
🌐
Reddit
reddit.com › r/learnjava › when to use int vs integer ?
r/learnjava on Reddit: When to use int vs Integer ?
August 8, 2021 -
import java.util.*;
class Main {  
  public static void main(String args[]) { 
	Integer[] a = {1,2};
	int[] b = {1,2};
	System.out.println(Arrays.toString(a));
	System.out.println(Arrays.toString(b));

  } 
}

Hi all, trying to learn Java from python background and run into some trouble.

So I have read that Integer is the object class and int is the binary primitive, and that Java compiler is now able to convert between them when nesessary.

But when should I use the primitive vs the object ? Generally speaking, all I can think of right now is that we should always use the primitives unless we may need to cast to another type in the future so then use object ones.

🌐
Oracle
docs.oracle.com › javame › config › cldc › ref-impl › cldc1.0 › jsr030 › java › lang › Integer.html
java.lang Class Integer
The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002d') to indicate a negative value. The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseInt(java.lang...
🌐
University of Washington
courses.cs.washington.edu › courses › cse341 › 98au › java › jdk1.2beta4 › docs › api › java › lang › Integer.html
Class java.lang.Integer
The string value of this property is then interpreted as an integer value, as per the Integer.decode method, and an Integer object representing this value is returned. The second argument is the default value. If there is no property of the specified name, or if the property does not have the correct numeric format, then the second argument is returned. ... System.getProperty(java.lang.String), System.getProperty(java.lang.String, java.lang.String), decode(java.lang.String)
🌐
DataCamp
datacamp.com › doc › java › int
int Keyword in Java: Usage & Examples
The int keyword in Java is a primitive data type that represents a 32-bit signed two's complement integer.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-lang-integer-class-java
Java.lang.Integer class in Java - GeeksforGeeks
June 21, 2022 - Java Collection · Last Updated : 21 Jun, 2022 · Integer class is a wrapper class for the primitive type int which contains several methods to effectively deal with an int value like converting it to a string representation, and vice-versa.