🌐
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.
🌐
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?
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 › 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.
🌐
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.
🌐
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.
Find elsewhere
🌐
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
🌐
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 › 22 › docs › api › java.base › java › lang › Integer.html
Integer (Java SE 22 & JDK 22)
July 16, 2024 - 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.
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 › 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.
🌐
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.
🌐
Android Developers
developer.android.com › api reference › integer
Integer | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
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.

🌐
Study.com
study.com › business courses › business 104: information systems and computer applications
Java Integer: Definition & Examples | Study.com
In other words, integers are similar to the set of whole numbers but add in the negative numbers as well. So, it is both positive and negative non-decimal numbers. When we talk about integers in computer programming languages like Java, we are talking about a similar thing.
🌐
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.
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-read-and-print-an-integer-value-in-java
How to Read and Print an Integer Value in Java - GeeksforGeeks
May 12, 2026 - It forms the base for performing calculations, conditions, and logical operations in Java programs · It explains different methods like Scanner and BufferedReader to take integer input from the user and display it on the screen.