DESKTOP-7HC873M_20200908-李宗宝
问题
public class Test{
static{
int x=5;
}
static int x,y;
public static void myMethod( ){
y=x++ + ++x;
}
}
public static void main(String args[]){
x--;
myMethod( );
System.out.println(x+y+ ++x);
}
输出结果为3.
为什么类初始化器中的x与类变量x不冲突???
心得
今天掉的坑有点多!!!
近期评论