public class A{
}
A a = new A(){{
final int x = 1; // IT HAS TO BE FINAL HERE. WHY?
}};
A aa = new A(){
int x = 1; // THIS NEED NOT BE FINAL. WHY?
final int y = 1; // STILL FINAL IS ALLOWED HERE. WHY?
public int getX(){
return x;
}
};
有人可以回答在代碼段中提到的問題嗎?Java中{}和{{}}初始化的區別
由於
有沒有解釋Java語言的基本細節的Java書? – user855
@ajay是的,它被稱爲[Java語言規範](http://java.sun.com/docs/books/jls/)。 –