class Example{
public static void main(String args[]){
int x=99;
if(x++==x){
System.out.println("x++==x : "+x); //Why this code line is not run?
}
if(++x==x ){
System.out.println("++x==x : "+x);
}
}
}
Run Code Online (Sandbox Code Playgroud)
为什么第一条语句没有println执行?
class Human {
void eat() {
System.out.println("human eat!");
}
}
public class Demo {
public static void main(String[] args) {
Human human = new Human() {
int x = 10;
public void test() {
System.out.println("test - anonymous");
}
@Override
void eat() {
System.out.println("customer eat!");
}
};
human.eat();
human.x = 10; //Illegal
human.test(); //Illegal
}
}
Run Code Online (Sandbox Code Playgroud)
这段代码为什么会human.x=10;出现human.test(0);编译错误?