Advertisement
Felanpro

static variable

Aug 26th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. class program1
  2. {
  3.    
  4.     public static void main(String[] args)
  5.     {
  6.         program1_class2 object1 = new program1_class2(); //First object
  7.         System.out.println(object1.myint += 1); //+ 1 to myint
  8.        
  9.         program1_class2 object2 = new program1_class2();
  10.         System.out.println(object1.myint);
  11.        
  12.         /*
  13.          * A static variable's value is shared among all objects of a class.
  14.         */
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement