SHOW:
|
|
- or go back to the newest paste.
| 1 | public class Test {
| |
| 2 | ||
| 3 | public static void main(String[] args) {
| |
| 4 | - | Outer.Static.method(); |
| 4 | + | Outer.Static.method(); // -> in static class |
| 5 | Outer instance = new Outer(); | |
| 6 | - | instance.field.method(); |
| 6 | + | instance.field.method(); // -> in non-static class |
| 7 | ||
| 8 | } | |
| 9 | ||
| 10 | } | |
| 11 | ||
| 12 | class Outer {
| |
| 13 | ||
| 14 | static class Static {
| |
| 15 | ||
| 16 | static void method() {
| |
| 17 | System.out.println("In static class");
| |
| 18 | } | |
| 19 | } | |
| 20 | ||
| 21 | NonStatic field = new NonStatic(); | |
| 22 | ||
| 23 | class NonStatic {
| |
| 24 | ||
| 25 | void method() {
| |
| 26 | System.out.println("In non-static class");
| |
| 27 | } | |
| 28 | } | |
| 29 | ||
| 30 | } |