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
to Warning
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 a Quick Fix
with a mouse right-click.
Go to Windows->Preference->Java->Compiler->Errors/Warnings
In that Unnecessary Code tab. Make Value of Parameter is not used
as Error
from Ignore
or Warning
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.