Skip to content

Instantly share code, notes, and snippets.

@solominh
Created January 21, 2017 23:31
Show Gist options
  • Save solominh/9b6de58d21f0c868be4c54ac9341e83e to your computer and use it in GitHub Desktop.
Save solominh/9b6de58d21f0c868be4c54ac9341e83e to your computer and use it in GitHub Desktop.
public class StaticProperty {
public static class Person {
static int staticProperty = 10;
String name;
public Person(String name) {
this.name = name;
}
}
public static void main(String[] args) {
Person john = new Person("john");
System.out.println(john.staticProperty); // 10
john.staticProperty = 5;
System.out.println(Person.staticProperty); // 5
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment