易错点:
static不能修饰局部变量
例题:1.如何代码输出的结果是什么?(D )
public class Test {
public int aMethod( ) {
static int i = 0;
i++;
return i;
}
public static void main (String args[]) {
Test test = new Test();
test.aMethod();
int j = test.aMethod();
System.out.println(j);
}
}
A. 0 B. 1 C. 2 D.编译失败
static不能用于直接声明类
static class MyClass { // 注意:这是错误的,static不能用于直接声明类
int myVariable = 10;
void myMethod() {


2286

被折叠的 条评论
为什么被折叠?



