Mega Code Archive

 
Categories / Java Tutorial / Class Definition
 

Inside main( ), the static method callme( ) and the static variable b are accessed outside of their class

class StaticDemo {   static int a = 42;   static int b = 99;   static void callme() {     System.out.println("a = " + a);   } }     class StaticByName {   public static void main(String args[]) {     StaticDemo.callme();     System.out.println("b = " + StaticDemo.b);   } }