You can use

Integer integer = Integer.valueOf(i);

From the javadoc of the constructor:

Deprecated. It is rarely appropriate to use this constructor. The static factory valueOf(int) is generally a better choice, as it is likely to yield significantly better space and time performance. Constructs a newly allocated Integer object that represents the specified int value.

The main difference is that you won't always get a new instance with valueOf as small Integer instances are cached.


All of the primitive wrapper types (Boolean, Byte, Char, Short, Integer, Long, Float and Double) have adopted the same pattern. In general, replace:

    new <WrapperType>(<primitiveType>)

with

    <WrapperType>.valueOf(<primitiveType>)

(Note that the caching behavior mentioned above differs with the type and the Java platform, but the Java 9+ deprecation applies notwithstanding these differences.)

Answer from Denys Séguret on Stack Overflow
🌐
GitHub
github.com › protocolbuffers › protobuf › issues › 8449
Deprecation warnings when compiling on JDK > 9: Integer(int) in Integer has been deprecated and marked for removal · Issue #8449 · protocolbuffers/protobuf
April 4, 2021 - Integer key = new Integer(number); java/core/src/main/java/com/google/protobuf/Descriptors.java:1763: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal Integer key = new Integer(number); ^ Reactions are currently ...
Author   protocolbuffers
Discussions

Integer has been deprecated and marked for removal
JRJdk13Compiler shows theses warnings:warning: [removal] Integer(int) in Integer has been deprecated and marked for removal value = new java.lang.Integer(1); //$JR_EXPR_ID=1$Most probably this deprecated syntax (new java.lang.Integer(int)) is used for initialization of Integer variables defined i... More on community.jaspersoft.com
🌐 community.jaspersoft.com
5
May 16, 2023
JDK 9 deprecates Number constructors, e.g. Integer(int)
I believe this isn't new, and has been going on for the last few versions at least. Industry-wide APIs are using more static code over the more Object-oriented ( Or "Instance" oriented? ) approach of the last decades. Constructors in general are used less, and static factory functions are used more. I've been doing this myself, using an "Immutable by default" approach to objects; "final" classes with all final members and with private constructors only but static factory methods. It seems that is tied to moving to a more Functional approach to languages and APIs. As higher concurrency requirements are causing this approach to look more attractive every day. More on reddit.com
🌐 r/java
72
144
September 16, 2016
Reports - Jasperreport - Integer has been deprecated and marked for removal value
While running the jasper report these warnings are shown: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal value = new java.lang.Integer(1); //$JR_EXPR_ID=1$ Most probably this deprecated syntax (new java.lang.Integer(int)) is used for initialization of ... More on forum.jmix.io
🌐 forum.jmix.io
0
0
May 14, 2023
Java Lesson 21 Integer Deprecated
After playing the Java Lesson 21 Practice Solution Walkthrough, when I pressed run, it printed: Question.java:18: error: Integer(int) in java.lang.Integer has been deprecated and marked for removal output.put(parts[i], new Integer(1)); ^ 1 error Here’s a screenshot: More on forum.learncs.online
🌐 forum.learncs.online
0
0
December 27, 2023
🌐
Jsparrow
jsparrow.github.io › rules › inefficient-constructor.html
Replace Inefficient Constructors with valueOf() | jSparrow Documentation
For example new Integer("1") becomes Integer.valueOf("1"). Using this rule saves memory and CPU cycles, as the constructors are not needed in this case. Furthermore, the constructors are deprecated in Java 9, which is an indication that they will eventually be removed from the language altogether.
🌐
Coderanch
coderanch.com › t › 773726 › java › replace-statement-deprecated-constructor
Should I replace a statement with a deprecated constructor? (Java in General forum at Coderanch)
June 28, 2023 - "The constructor Integer(int) has been deprecated since version 9 and marked for removal"·. While it still works, is it going to work in the future?
🌐
Oracle
docs.oracle.com › javase › › 9 › docs › api › java › lang › Integer.html
Integer (Java SE 9 & JDK 9 )
Integer result = getInteger(nm, null); return (result == null) ? new Integer(val) : result; to avoid the unnecessary allocation of an Integer object when the default value is not needed. ... Returns the integer value of the system property with the specified name.
🌐
Jaspersoft Community
community.jaspersoft.com › home › forum › integer has been deprecated and marked for removal
Integer has been deprecated and marked for removal - Products - Jaspersoft Community
May 16, 2023 - JRJdk13Compiler shows theses warnings:warning: [removal] Integer(int) in Integer has been deprecated and marked for removal value = new java.lang.Integer(1); //$JR_EXPR_ID=1$Most probably this deprecated syntax (new java.lang.Integer(int)) is used for initialization of Integer variables defined i...
🌐
TutsWiki
tutswiki.com › java › wrapper-class
Wrapper Class in Java :: TutsWiki Beta
void wrapperClassExample1(){ Integer int1 = new Integer(1); // Deprecated since, Java 9 System.out.println(int1); Integer int2 = Integer.valueOf(2); System.out.println(int2); // Calculating Sum System.out.println(int1 + int2); // Example with another type Character another = Character.valueOf('a'); ...
🌐
Reddit
reddit.com › r/java › jdk 9 deprecates number constructors, e.g. integer(int)
r/java on Reddit: JDK 9 deprecates Number constructors, e.g. Integer(int)
September 16, 2016 - Java 9 is expanding the @Deprecated ... more aggressive in this area. ... There're both of two constructors, viz: Integer(int value) and Integer(String s) deprecated starting from JDK 9....
Find elsewhere
🌐
Jmix
forum.jmix.io › support
Reports - Jasperreport - Integer has been deprecated and marked for removal value - Support - Jmix
May 14, 2023 - While running the jasper report these warnings are shown: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal value = new java.lang.Integer(1); //$JR_EXPR_ID=1$ Most probably this deprecated syntax (new ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › the-deprecated-annotation-in-java
The @Deprecated Annotation in Java - GeeksforGeeks
August 17, 2022 - ... // Java Program Illustrating ... @Deprecated // Declaring and initializing integer variables int number = 100; // New field final int newnumber = 100; // Main public static void main(String a[]) { // Creating an object ...
🌐
Eclipse
bugs.eclipse.org › bugs › show_bug.cgi
489986 – Replace new Integer() with Integer.valueOf() in org.eclipse.test
Bugzilla – Bug 489986 Replace new Integer() with Integer.valueOf() in org.eclipse.test Last modified: 2017-01-18 11:08:40 EST
🌐
OpenJDK
bugs.openjdk.org › browse › JDK-8354338
No longer deprecate wrapper class constructors for removal
April 10, 2025 - diff --git a/src/java.base/share/classes/java/lang/Integer.java b/src/java.base/share/classes/java/lang/Integer.java index a6bf739220f..78e124c2ea5 100644 --- a/src/java.base/share/classes/java/lang/Integer.java +++ b/src/java.base/share/classes/java/lang/Integer.java @@ -1024,7 +1024,7 @@ public static Integer valueOf(int i) { * {@link #valueOf(int)} is generally a better choice, as it is * likely to yield significantly better space and time performance. */ - @Deprecated(since="9", forRemoval = true) + @Deprecated(since="9") public Integer(int value) { this.value = value; } @@ -1046,7 +1046,7 @@ public Integer(int value) { * {@code int} primitive, or use {@link #valueOf(String)} * to convert a string to an {@code Integer} object.
🌐
Learncs
forum.learncs.online › bug reports
Java Lesson 21 Integer Deprecated - Bug Reports - learncs.online
December 27, 2023 - After playing the Java Lesson 21 Practice Solution Walkthrough, when I pressed run, it printed: Question.java:18: error: Integer(int) in java.lang.Integer has been deprecated and marked for removal output.put(parts[i], new Integer(1)); ^ 1 error ...
🌐
GitHub
github.com › protocolbuffers › protobuf › issues › 8462
Descriptors.java:1763: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal · Issue #8462 · protocolbuffers/protobuf
April 7, 2021 - $ bazel build --config=java16 ... [removal] Integer(int) in Integer has been deprecated and marked for removal Integer key = new Integer(number); ^ Target //java/com/google/gerrit/common:server up-to-date: bazel-bin/java/co...
Author   protocolbuffers
🌐
Sonar Community
community.sonarsource.com › sonarqube for ide › intellij platform
New Integer(String s) reported as Deprecated in Java 8 and IntelliJ 2019.1 beta - IntelliJ Platform - Sonar Community
March 15, 2019 - I have this line in my project, using Java 8 as my SDK, IntelliJ 2019.1 beta: Integer myInteger = new Integer(parameter.getUnescapedDefaultValue()); (where parameter.getUnescapedDefaultValue() returns a String).
🌐
Oracle
docs.oracle.com › javase › 10 › docs › api › java › lang › Integer.html
Integer (Java SE 10 & JDK 10 )
Integer result = getInteger(nm, null); return (result == null) ? new Integer(val) : result; to avoid the unnecessary allocation of an Integer object when the default value is not needed. ... Returns the integer value of the system property with the specified name.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.integer.-ctor
Integer Constructor (Java.Lang) | Microsoft Learn
Constructs a newly allocated Integer object that represents the int value indicated by the String parameter. The string is converted to an int value in exactly the manner used by the parseInt method for radix 10.