class ClassB {
int c=0;
public static void main(String [] args) {
ClassA cla = new ClassA();
c=cla.getValue();
}
}
class ClassA {
int value = 0;
public int getValue() {
ClassA obj=new ClassA();
return obj.value;
}
}
I want to 'int value' of ClassA in 'int c' of class B. The above code shows the error "non static variable c cannot be referred from a static context". Please provide the correct coding for me as I am stuck.