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 - The use of new Integer(int) here is deprecated in JDK 9 and marked for removal, see Deprecation of Boxed Primitive Constructors. // Note: We must use "new Integer(number)" here because we don't want // these Integer objects to be cached. 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); ^
Author   protocolbuffers
🌐
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
Discussions

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 - The constructors Integer(int), Double(double), Long(long) and so on are deprecated - Stack Overflow
While working, I got the warning The constructor Integer(int) is deprecated and I couldn't find an alternative constructor/solution online. How can I resolve this issue? I will get a similar warn... More on stackoverflow.com
🌐 stackoverflow.com
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
e Messages jGRASP Messages Run I/O Interactions Chapter24_2.java:31: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal list.remove(new Integer (1)); Note: Chapter24_2.java uses unchecked or unsafe operations. Note: Recompile with -Xlint: unchecked for details.
Answer to e Messages jGRASP Messages Run I/O Interactions More on chegg.com
🌐 chegg.com
1
February 27, 2023
🌐
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...
🌐
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 java.lang.Integer(int)) is used for initialization of Integer variables defined in the report (built-in variables) instead of Integer.valueOf(int).
🌐
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 reason for using Integer is the value is added to a vector for some bookkeeping (at some point the vector's contains method is called) so I guess the parameter must be an object. Perhaps using a vector is not the best of options and a list would be more appropriate, but first I'll study this working code and eventually I'll make my modifications. ... Yes, at some point you should replace Vector with List. You can add an int to a List<Integer>. In general, whenever an assignment context expects a wrapper type such as Integer, you can assign a primitive type (such as int) directly to it.
🌐
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 Here’s a screenshot:
🌐
Eclipse
bugs.eclipse.org › bugs › › show_bug.cgi
570194 – [16] warnings for The constructor Integer(int) has been deprecated and marked for removal
Bugzilla – Bug 570194 [16] warnings for The constructor Integer(int) has been deprecated and marked for removal Last modified: 2021-02-28 23:38:42 EST
Find elsewhere
🌐
OpenJDK
bugs.openjdk.org › browse › JDK-8354338
No longer deprecate wrapper class constructors for removal
April 10, 2025 - Revert them to simply "deprecated". The constructors of primitive wrapper classes like Integer have been deprecated since Java 9, because they force the creation of wrapper objects with new identities, and it has long been discouraged to depend on the identity of a wrapper object.
🌐
Apache JIRA
issues.apache.org › jira › browse › JDO-810
[#JDO-810] Fix Java 9 warnings - ASF JIRA
[WARNING] [options] bootstrap class path not set in conjunction with -source 8 [WARNING] C:\work\github\db-jdo\api\src\main\java\javax\jdo\spi\JDOImplHelper.java:[781,32] [removal] Integer(int) in Integer has been deprecated and marked for removal [WARNING] C:\work\github\db-jdo\api\src\main\java\javax\jdo\spi\I18NHelper.java:[357,25] [removal] Integer(int) in Integer has been deprecated and marked for removal [WARNING] C:\work\github\db-jdo\api\src\main\java\javax\jdo\PersistenceManager.java:[566,36] [unchecked] Possible heap pollution from parameterized vararg type T where T is a type-variab
🌐
GitHub
github.com › TheThirdOne › rars › issues › 149
Warning while building from sources · Issue #149 · TheThirdOne/rars
February 15, 2022 - src/rars/venus/NumberDisplayBaseChooser.java:224: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal return new Integer(value).toString(); ^ Note: Some input files use or override a deprecated API.
Author   TheThirdOne
🌐
IT Solutions
solutionfall.com › home › questions › was integer(int) in integer deprecated and marked for removal?
Was Integer(int) in Integer deprecated and marked for removal? - IT Solutions | Free tech support | SolutionFall.Com
August 12, 2024 - Yes, the constructor Integer(int) in the Integer class has been deprecated starting from Java 9 and is marked for removal in a future release. This means that it is advised to avoid using this constructor as it may be removed in a future version of Java.
🌐
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 - They haven't been removed, for backwards compatibility. Java 9 is expanding the @Deprecated annotation to enable tagging of certain things that should be truly removed because they are actively harmful.
🌐
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 - The Class instance representing the primitive type int. ... Deprecated, for removal: This API element is subject to removal in a future version.
🌐
Eclipse
bugs.eclipse.org › bugs › show_bug.cgi
580917 – Fix deprecated warnings - Eclipse bug
Download · Getting Started · Members · Projects · Community · Marketplace · Events · Planet Eclipse · Videos · Participate
🌐
GitHub
github.com › RadixIoT › BACnet4J › issues › 76
LocalDevice uses deprecated new Integer(int value) · Issue #76 · RadixIoT/BACnet4J
November 16, 2022 - Describe the bug Use of deprecated new Integer() constructor. To Reproduce Steps to reproduce the behavior: Compile using Java 9+ Expected behavior No warnings. Actual Error LocalDevice.java:336: warning: [removal] Integer(int) in Intege...
Author   RadixIoT
🌐
OpenJDK
bugs.openjdk.org › browse › JDK-8254324
[JEP 390] Deprecate wrapper class constructors for removal
Recompiling from source will see new warnings for existing uses of the constructors. ... The primitive wrapper constructors are being deprecated for removal, they have been deprecated since JDK 9. The classes with constructors to be deprecated for removal are java.lang.Boolean, java.lang.Byte, java.lang.Character, java.lang.Short, java.lang.Integer, java.lang.Long, java.lang.Float, and java.lang.Double.
🌐
Oracle
docs.oracle.com › javase › › 9 › docs › api › java › lang › Integer.html
Integer (Java SE 9 & JDK 9 )
Constructs a newly allocated Integer object that represents the specified int value. ... Deprecated. It is rarely appropriate to use this constructor.
🌐
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