Use checkstyle and configure the UnusedImports module to be used (or select the default configuration that already uses it).
Checkstyle defines unused imports as:
- Import without wildcards that is not specified in the file.
- An import that is a duplicate of another import.
- Import from
java.lang . - Import from the same package as the class.
- (optional) import, which is only needed to resolve the JavaDoc link.
In practice, a report is created in which java.awt.Component not used (along with the line number).
import java.awt.Component; class FooBar { ... }
It has some limitations, in the sense that they can be confused by members with the same name as the import; but this error rarely finds its practice for most developers.
From the documentation regarding the restriction
import java.awt.Component; class FooBar { private Object Component;
You cannot use the Component flag.
source share