mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
38 lines
798 B
HTML
38 lines
798 B
HTML
<html>
|
|
<body>
|
|
Reports anonymous classes.
|
|
<p>Occasionally replacing anonymous classes with inner classes can lead to more readable and maintainable code.
|
|
Some code standards discourage anonymous classes.</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
class Example {
|
|
public static void main(String[] args) {
|
|
new Thread() {
|
|
public void run() {
|
|
work()
|
|
}
|
|
|
|
private void work() {}
|
|
}.start();
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
class Example {
|
|
public static void main(String[] args) {
|
|
new MyThread().start();
|
|
}
|
|
|
|
private static class MyThread extends Thread {
|
|
public void run() {
|
|
work();
|
|
}
|
|
|
|
private void work() {}
|
|
}
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |