我有一个带有枚举的User类:
public class User
{
private int index;
private enum Counter
{
INSTANCE;
private int objects;
protected int getObjects()
{
return objects;
}
protected void setObjects()
{
this.objects++;
}
}
public User(){
this.index = User.Counter.INSTANCE.getObjects();
User.Counter.INSTANCE.setObjects();
}
}
在本课程中,我仍然能够做到
this.index = User.Counter.INSTANCE.objects; //in public User()
如何使这条线变得无效?