I am trying to access int a= 10 variable in child class but getting error:
Cannot make a static reference to the non-static field FreshJuice.a
Following is my code.
class FreshJuice {
enum FreshJuiceSize{SMALL,MEDIUM,LARGE};
FreshJuiceSize size;
int a = 10;
}
public class Index extends FreshJuice {
enum programmingLanguage{PHP,Java,Dotnet,HTML};
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(FreshJuice.FreshJuiceSize.SMALL);
System.out.println(programmingLanguage.PHP);
System.out.println(FreshJuice.a); //getting error in this line
}
}
I want to directly access int variable of FreshJuice class in child class. How can i achieve this target?