I am getting this checkstyle error:
'serverURL' hides a field
in this
private static void setServerURL(final String serverURL) {
Utility.serverURL = serverURL;
}
What could be the reason, and how to resolve it?
checkstyleeclipsejava
I am getting this checkstyle error:
'serverURL' hides a field
in this
private static void setServerURL(final String serverURL) {
Utility.serverURL = serverURL;
}
What could be the reason, and how to resolve it?
Best Answer
There is already a variable defined
serverURL
which is available to this method (additional to the formal parameter you are accepting). This is called "shadowing".I think most Java programmers turn this check off, because it's not really that confusing.
For example, this would trigger the error: