0

Just read that non-static method cannot rewrite static variables.Tried and found otherwise can somebody explains ?

Java static non-static differences

9th Jun 2019, 5:42 PM
Atul Singh
Atul Singh - avatar
1 Réponse
0
Apparently, it was written on the contrary. Like: "non-static variable a cannot be referenced from a static context" because non-static can rewrite static: public class Program { static int a=0; public static void main(String[] args) { new Program().test(); System.out.println(a); //1 } void test() { a = 1; } }
9th Jun 2019, 8:48 PM
zemiak