CODEARTS IDE-尽可能使用Interface:重构前

时间:2024-04-16 15:05:26

重构前

class UseInterface {

    public static void main(String[] args) {
        InnerClass innerClass = new InnerClass();
        print(innerClass);
    }

    private static void print(InnerClass innerClass) {
        innerClass.print();
    }

    private static class InnerClass implements InnerInterface {
        @Override
        public void print() {
            System.out.println("Hello World!");
        }
    }

    private static interface InnerInterface{
        void print();
    }
}
support.huaweicloud.com/usermanual-codeartside/codeartside_01_0155.html