I have a bunch of classes which contain constructors with unused parameters. For example this one:
class Book {
String author;
String title;
public Book(String author, String title, int numberOfPages) {
this.author = author;
this.title = title;
}
}
Does Eclipse offer any way of automatically removing these unused parameters over multiple files? Removing them manually would take hours.
On Eclipse Juno, you can set the compiler to show a warning/error when there's an unused parameter.
Window
->Preferences
Java
->Compiler
->Errors/Warnings
Unnecessary code
Value of parameter is not used
toWarning
or (better)Error
.This way the compiler will show a warning or will even fail to compile if there are unused method/constructor parameters.
In this case, when you navigate to the
Problems
view, you can apply aQuick Fix
with a mouse right-click.