匿名内部类实现接口
package project3;
public class Initail {
public static void main(String[] args) {
// TODO Auto-generated method stub
Telphone tell = new CellPhone();
tell.call();
tell.message();
Telphone tel2 = new SmartPhone();
tel2.call();
tel2.message();
IPlayGame ip1 = new SmartPhone();
ip1.playGame();
IPlayGame ip2 = new Psp();
ip2.playGame();
}
IPlayGame ip4 = new IPlayGame() {
@Override
public void playGame() {
// TODO Auto-generated method stub
System.out.println("使用匿名内部类方法实现接口");
}
};
ip4.playGame();//这个错了
}
//这是原因,不知道怎么错的,求大神解释:Syntax error on token "playGame", Identifier expected after this token