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

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
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
Deprecation warnings when compiling on JDK > 9: Integer(int) in Integer has been deprecated and marked for removal
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 wan... More on github.com
🌐 github.com
2
April 4, 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
🌐
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 - Deprecated, for removal: This API element is subject to removal in a future version. 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.
🌐
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 ... in this area. ... There're both of two constructors, viz: Integer(int value) and Integer(String s) deprecated starting from JDK 9....
🌐
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 › 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 wan...
Author   protocolbuffers
🌐
OpenJDK
bugs.openjdk.org › browse › JDK-8354338
No longer deprecate wrapper class constructors for removal
April 10, 2025 - 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.
🌐
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).
Find elsewhere
🌐
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.
🌐
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, ... = new Integer(parameter.getUnescapedDefaultValue()); (where parameter.getUnescapedDefaultValue() returns a String). SonarLint flags it as a Code Smell due to rule squid:CallToDeprecatedMethod; however, such constructor has been marked as @Deprecated in Java 9 and still ...
🌐
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 - Deprecated, for removal: This API element is subject to removal in a future version. 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.
🌐
JavaWhizz
javawhizz.com › home › blog › how to update deprecated code in java
How to update deprecated code in Java
July 24, 2023 - Go to the tutorial and follow through to create a new project. Select IntelliJ in the Build System section to create a console application. In your base package, create a file named WithDeprecation.java. Copy and paste the following code into the file. package com.javawhizz; public class WithDeprecation { public Integer stringToInt() { String number = "200"; //FIXME: This constructor is deprecated return new Integer(number); } }
🌐
OpenJDK
bugs.openjdk.org › browse › JDK-8257512
Remove use of deprecated primitive constructors in JavaFX
The primitive constructors ("new Double", "New Integer", etc) were deprecated in JDK 9, and will be terminally deprecated in JDK 16 for subsequent removal.
🌐
University of San Francisco Computer Science
cs.usfca.edu › ~cs212 › javadoc › api › deprecated-list.html
Deprecated List (Java SE 16 & JDK 16)
All of the classes and interfaces in this package have been terminally deprecated. The rmid tool has also been terminally deprecated. There is no replacement for the RMI Activation mechanism in the Java Platform.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.integer.-ctor
Integer Constructor (Java.Lang) | Microsoft Learn
[<Android.Runtime.Register(".ctor", "(I)V", "")>] new Java.Lang.Integer : int -> Java.Lang.Integer ... Constructs a newly allocated Integer object that represents the specified int value. This member is deprecated. It is rarely appropriate to ...
🌐
Apache JIRA
issues.apache.org › jira › browse › GUACAMOLE-497
[GUACAMOLE-497] Ensure guacamole-client source is compatible with Java 9 - ASF JIRA
guacamole-client is intended to ... Java 9, resulting in warnings and a failed build: Wrapper class constructors new Integer(String) and new Long(String) have been deprecated in favor of Integer.valueOf(String) and Long.valueOf(String)....
🌐
AstroDeck
xspdf.com › resolution › 59923670.html
xspdf — PDF Generation & Processing API for Developers | xspdf
Powerful PDF API for developers. Generate, convert, merge, split, compress, protect and extract PDFs programmatically. RESTful API with simple integration.