Static Methods - Please help!
I'm having trouble figuring out why these two codes do NOT give the same output. They look exactly the same to me - I'm so confused. For context, these examples were given under the 'static' topic in java. You can find them below. Java > Classes and Objects > Static > First "Try it your self" example. vs Java > Classes and Objects > Static > Last Question /* public class DemoStaticVariables { public static int pCount; public static void main(String[ ] args) { DemoStaticVariables.pCount=0; DemoStaticVariables.pCount++; System.out.println(DemoStaticVariables.pCount); } } //Outputs 1 */ /* class Counter{ public static int COUNT=0; Counter(){ COUNT++; } } public class DemoStaticVariables { public static void main(String[ ] args) { System.out.println(Counter.COUNT); } } //Outputs 0 */