Static modifier

public class Static {
    static int x = 0 ;
    public static void main(String[] args) {
        Static a = new Static();
        Static b = new Static();
        System.out.println(b.x);
        a.x = 1;
        System.out.println(b.x);
    }
}

 

result:

0

1

 

The following warning is ignored anyway...

The static field Static.x should be accessed in a static way

你可能感兴趣的:(Modifier)