abstract class Shap {
    static String str = "shap:";
    abstract void show();
}
class Picture {
    Picture(String str) {
        System.out.println("paint a picture: " + str);
    }
    void show() {
        System.out.println("a picture: ");
    }
   abstract class Shap {
    static String str = "shap:";
abstract void show();
}
class Picture {
    Picture(String str) {
        System.out.println("paint a picture: " + str);
    }
    void show() {
        System.out.println("a picture: ");
    }
    public Shap paint(final int r) {
        Shap shap;
        shap = new Shap() {                              // 父类对象指向匿名内部类实例
            void show() {
                System.out.println(Shap.str);               // 访问父类的静态属性
                System.out.println("paint a circle radius =" + r);
            }
        };                                             // 内部类结束，以；结束
        return shap;
    }
    public Picture paint() {
        return new Picture("tree") { // 父类是外包类
            void show() {
                System.out.println("paint a beautiful picture");  // 重写父类的方法
            }
        };                                              // 内部类结束
    }
}
public class Example4_17{
    public static void main(String[] args) {
        Picture pic = new Picture("mountain");
        Shap shap = pic.paint(5);
        shap.show();
        Picture p = pic.paint();
        p.show();                                        // 访问被内部类重写的方法
    }
}

