Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. public class StaticProperty {
  2. public static class Person {
  3.  
  4. static int staticProperty = 10;
  5. String name;
  6.  
  7. public Person(String name) {
  8. this.name = name;
  9. }
  10.  
  11. }
  12.  
  13. public static void main(String[] args) {
  14. Person john = new Person("john");
  15. System.out.println(john.staticProperty); // 10
  16. john.staticProperty = 5;
  17. System.out.println(Person.staticProperty); // 5
  18. }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement