草貌路飞 发表于 2013-7-25 11:41
匿名内部类倒是可以用
playInstrument(new Instrument()
{
草貌路飞 发表于 2013-7-25 19:38
匿名内部类呀 不是直接new一个Instrument的对象,而是匿名的给它创建了一个子类对象 ...
xscn 发表于 2013-7-25 21:11
你的意思是不是这样?其实就是多态嘛,父类引用Instrument in指向子类对象,只不过换成匿名对象,不过不推 ...
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |