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
🌐
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...
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
Warning while building from sources
Here is a log: 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: More on github.com
🌐 github.com
0
February 15, 2022
🌐
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
🌐
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 - I copied this statement from some code I found out there: which appears crossed off in the Eclipse IDE and hovering the mouse this message is shown: "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?
🌐
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 - Undo the change from JEP 390 that marked constructors of the primitive wrapper classes as "deprecated for removal". 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 ...
🌐
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.
🌐
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
🌐
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.
🌐
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
🌐
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 › 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. It is rarely appropriate to use this constructor. All MethodsStatic MethodsInstance MethodsConcrete Methods ... Returns the number of one-bits in the two's complement binary representation of the specified ...
🌐
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
🌐
Oracle
docs.oracle.com › javase › › 9 › docs › api › java › lang › Integer.html
Integer (Java SE 9 & JDK 9 )
The number of bytes used to represent an int value in two's complement binary form. ... 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