mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
31 lines
822 B
HTML
31 lines
822 B
HTML
<html>
|
|
<body>
|
|
Reports instance initializers which may be made <code>static</code>.
|
|
<p>
|
|
An instance initializer may be static if it does not reference any of its class' non-static members.
|
|
Static initializers are executed once the class is resolved,
|
|
while instance initializers are executed on each instantiation of the class.</p>
|
|
<p>This inspection doesn't report instance empty initializers and initializers in anonymous classes.
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
class A {
|
|
public static String CONSTANT;
|
|
{
|
|
CONSTANT = "Hello";
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
class A {
|
|
public static String CONSTANT;
|
|
static {
|
|
CONSTANT = "Hello"; //now initialized only once per class
|
|
}
|
|
}
|
|
</code></pre>
|
|
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html>
|