当前位置: 技术问答>java相关
a problem about anonymous inner!!
来源: 互联网 发布时间:2015-02-24
本文导语: 15. Which of the following statements are true? A) An anonymous class cannot have any constructors B) An anonymous class can only be created within the body of a method C) An anonymous class can only access static fields of the enclosing cl...
15. Which of the following statements are true?
A) An anonymous class cannot have any constructors
B) An anonymous class can only be created within the body of a method
C) An anonymous class can only access static fields of the enclosing class
D) An anonymous class instantiated and declared in the same place.
C)为什么不对?能否举个例子?
A) An anonymous class cannot have any constructors
B) An anonymous class can only be created within the body of a method
C) An anonymous class can only access static fields of the enclosing class
D) An anonymous class instantiated and declared in the same place.
C)为什么不对?能否举个例子?
|
give me fen!
|
应该还可以访问final
|
f.addMouseMotionListener ( new MouseMotionAdapter() {
public void mouseDragged (MouseEvent e) {
String s = "Mouse dragging: X = " + e.getX() + " Y = " + e.getY();
tf.setText (s);
}
} );
注意tf,它可不是static
public void mouseDragged (MouseEvent e) {
String s = "Mouse dragging: X = " + e.getX() + " Y = " + e.getY();
tf.setText (s);
}
} );
注意tf,它可不是static