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
🌐
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 - 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. Java will automatically convert the int to an Integer.
Discussions

Integer has been deprecated and marked for removal
https://community.jaspersoft.com/forums/topic/67542-integer-has-been-deprecated-and-marked-for-removal/ More on community.jaspersoft.com
🌐 community.jaspersoft.com
5
May 16, 2023
Descriptors.java:1763: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal
After migration of Gerrit Code Review: [1] to build with Java 16 with Bazel, I'm seeing this deprecation warning on this code: https://github.com/protocolbuffers/protobuf/blob/master/java/core/... More on github.com
🌐 github.com
3
April 7, 2021
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
🌐
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...
🌐
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 - Descriptors.java:1763: warning: [removal] Integer(int) in Integer has been deprecated and marked for removal#8462
Author   protocolbuffers
🌐
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).
🌐
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.
🌐
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 - Deprecated, for removal: This API element is subject to removal in a future version.
🌐
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. It looks like they are getting more aggressive in this area. ... There're both of two constructors, viz: Integer(int value) and Integer(String s) deprecated starting from JDK 9....
🌐
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\ma...
🌐
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.
🌐
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. Note: Recompile with -Xlint:deprecation for details.
Author   TheThirdOne
🌐
Eclipse
bugs.eclipse.org › bugs › show_bug.cgi
489986 – Replace new Integer() with Integer.valueOf() in org.eclipse.test
Download · Getting Started · Members · Projects · Community · Marketplace · Events · Planet Eclipse · Videos · Participate
🌐
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. Tags · Free, Java 5, Coding Conventions, Performance, Marker ·
🌐
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
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.