- abstract class Demo{
- abstract void show();
- }
- class Outer{
- int num = 4;
- void method(){
- //匿名内部类
- new Demo(){
- void show(){
- System.out.println("show ..."+num);
- }
- }.show();
- }
- }
- public class AnonymousClassDemo {
- public static void main(String[] args){
- new Outer().method();
- }
- }
复制代码 |
|