Skip to content

Instantly share code, notes, and snippets.

@sivabudh
Created February 25, 2014 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivabudh/9202766 to your computer and use it in GitHub Desktop.
Save sivabudh/9202766 to your computer and use it in GitHub Desktop.
class MyRobo {
int x = 5;
static int y = 6;
}
class Untitled {
public static void main(String[] args) {
MyRobo robo1 = new MyRobo();
MyRobo robo2 = new MyRobo();
robo1.x += 1;
robo2.x += 1;
System.out.println(robo1.x);
System.out.println(robo2.x);
robo1.y += 1;
robo2.y += 1;
System.out.println(robo1.y);
System.out.println(robo2.y);
MyRobo robo3 = new MyRobo();
System.out.println(robo3.y);
}
}
@sivabudh
Copy link
Author

Printed output:

6
6
8
8
8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment