public class Main {
public static void main(String[] args) {
/**
* 这里面不应该有private这种限定符
*/
private int a = 1;
int b = 2;
protected int c = 3;
public int d = 4;
System.out.println(a + " " + b + " " + c + " " + d);
}
}
改写如下
public class Main {
private int a = 1;
int b = 2;
protected int c = 3;
public int d = 4;
public static void main(String[] args) {
Main m = new Main();
m.display();
}
private void display() {
System.out.println(a + " " + b + " " + c + " " + d);
}
}
或者
public class Main {
private static int a = 1;
static int b = 2;
static protected int c = 3;
static public int d = 4;
public static void main(String[] args) {
System.out.println(a + " " + b + " " + c + " " + d);
}
}