国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

java - abstract inner class + generics
給我你的懷抱
給我你的懷抱 2017-05-17 10:00:28
0
1
989

Simple inner class usage:

public class OuterClass {
    public OuterClass() {
    }

    public abstract class InnerAbstractClass {
        public void a() {

        }
        public abstract void absMethod();
    }
    
    public void test() {
        new OuterClass().new InnerAbstractClass() {
            public void absMethod() {

            }
        };
    }
    
    public static void main(String[] args) {

        new OuterClass().new InnerAbstractClass() {
            public void absMethod() {

            }
        };
    }
}

Add generics to the above example

public class OuterClass<T> {
    public OuterClass() {
    }

    public abstract class InnerAbstractClass {
        public void a() {

        }
        public abstract void absMethod();
    }

    public void test() {
        new OuterClass().new InnerAbstractClass() {
            public void absMethod() {

            }
        };
    }

    public static void main(String[] args) {

        new OuterClass().new InnerAbstractClass() {
            public void absMethod() {

            }
        };
    }
}

Call the inner class in the test method and compile correctly. An error is reported in the main method, cannot be referenced from a static context.
No error will be reported if an internal class is called in another newly created class

public class OuterClassTest {
    public static void main(String[] args) {
        new OuterClass().new InnerAbstractClass() {
            public void absMethod() {

            }
        };
    }
}

Why? ? ?

給我你的懷抱
給我你的懷抱

reply all(1)
巴扎黑

Haha, click on the unhelpful person, copy the code and run it yourself, it will compile without any problem! no problem!

If you don’t know how to use IDE, just use javac

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template