java基础-static修饰局部变量7.现在有如下⼀段代码
public class Test {
public int aMethod() {
static int i=0;
i++;
return i;
static修饰的变量}
public static void main(String args[]) {
Test test = new Test();
test.aMethod();
int j = test.aMethod();
System.out.println(j);
}
}
将产⽣哪种结果?
A. Compilation will fail
B. Compilation will succeed and the program will print“0”
C. Compilation will succeed and the program will print“1”
D. Compilation will succeed and the program will print“2”
正确答案是:A
Compilation will fail    编译将失败
报错信息:Illegal modifier for parameter i; only final is permitted
报错信息:参数i的修饰符⾮法;只允许final
原因:报错,⽆论是普通局部⽅法还是静态局部⽅法,内部的局部变量都不能有修饰符