Why use method local abstract inner classes

后端 未结 10 1799
名媛妹妹
名媛妹妹 2021-02-05 04:45

One of the legal modifiers you can use with method local inner classes is abstract.

For example:

public class Outer {
    public void method(){
        a         


        
10条回答
  •  佛祖请我去吃肉
    2021-02-05 05:29

    I can think only in this case

    class Outer {
        public void method() {
            abstract class A {
                void bar(){}
                abstract void foo();
            }
            class B extends A {
                @Override
                void foo() {
                }
            }
            final class C extends A {
                @Override
                void foo() {
                }
            }
            A a1 = new B();
            A a2 = new C();
        }
    }
    

    But I can't imagine real usage

提交回复
热议问题