java - unqualified access to field - this
I am working on a java project on Eclipse on win 7.
Now, I was working on the same project before on a different eclipse version on Linux. So while working on the Linux system all was fine. All of the sudden when I transferred the project to the win 7 computer, every place that I refer to one of the constructors data members, the compiler gives a warning that
unqualified access to field
If I add "this._member", then it is fine.
Why do I need to add this and why didn开发者_运维技巧't the compiler give me a warning before?
public class SoundWave {
private int _sr ;
public SoundWave (int sr){
_sr = sr ;
}
}
It is a specific setting of your Eclipse IDE, you can find it in preferences under Java Compiler:
just disable it and everything will be fine :)
In Eclipse, go to Window --> Preferences, and then navigate the tree menu to Java --> Compiler --> Errors/Warnings. Under the Code Style section you should see an option for Unqualified access to instance field. Change the option to "Ignore".
I imagine this option was not set to "Ignore" in your older setup which is why you weren't seeing the warnings.
精彩评论