Files
openide/java/java-impl/resources/inspectionDescriptions/CachedNumberConstructorCall.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

30 lines
1.2 KiB
HTML

<html>
<body>
Reports instantiations of new <code>Long</code>,
<code>Integer</code>, <code>Short</code>, or
<code>Byte</code> objects that have a primitive <code>long</code>,
<code>integer</code>, <code>short</code>, or
<code>byte</code>
argument.
<p>It is recommended that you use the static method <code>valueOf()</code>
introduced in Java 5. By default, this method caches objects for values between -128 and
127 inclusive.
<p><b>Example:</b></p>
<pre><code>
Integer i = new Integer(1);
Long l = new Long(1L);
</code></pre>
<p>After the quick-fix is applied, the code changes to:</p>
<pre><code>
Integer i = Integer.valueOf(1);
Long l = Long.valueOf(1L);
</code></pre>
<!-- tooltip end -->
<p>This inspection only reports if the language level of the project or module is 5 or higher</p>
<p>
Use the <b>Ignore new number expressions with a String argument</b> option to ignore calls to number constructors with a <code>String</code> argument.</p>
<p>
Use the <b>Report only when constructor is @Deprecated</b> option to only report calls to deprecated constructors.
<code>Long</code>, <code>Integer</code>, <code>Short</code> and <code>Byte</code> constructors are deprecated since JDK 9.</p>
</body>
</html>