This appears to create an object from an interface; how does it work?

前端 未结 4 880
鱼传尺愫
鱼传尺愫 2020-12-02 17:50
interface Int {
    public void show();
}

public class Test {     
    public static void main(String[] args) {
        Int t1 = new Int() {
            public void         


        
4条回答
  •  爱一瞬间的悲伤
    2020-12-02 18:34

    You're defining an anonymous class that implements the interface Int, and immediately creating an object of type thatAnonymousClassYouJustMade.

提交回复
热议问题