Example:
public class Counter { private int count; public static void main(String args[]){ System.out.println(count); //compile time error } } Example 2:
public class Counter { public int count = 0; } public class MyProgram { public static void main(String args[]){ Counter c = new Counter(); System.out.println(c.count); //OK } }
Counter c = new Counter(); System.out.println(c.count);Counter c = new Counter(); System.out.println(c.count);which by the way will work fine? - Regent