I created a enum with one private member variable. When i try to access the member variable the compiles states \'Cannot make a static reference to the non-static field memb
The main cause of error is : you are trying to make reference to private variable (memberVariable
) of super class from inner implementation class.
To make error free code you can do either of following :
super.memberVariable
since memberVariable
is not local to TheOnlyAndOnly()
int memberVariable
public.you can do:
TheOneAndOnly(1) {
int memberVariable=4;
@Override
public int addValue(final int value) {
return memberVariable + value;
}
};