Curly braces in “new” expression? (e.g. “new MyClass() { … }”)

前端 未结 3 710
鱼传尺愫
鱼传尺愫 2020-11-28 13:37

What do the curly braces do there ?

handler1 = new Handler() {

        public void handleMessage() {

       }
};

object = new Class

3条回答
  •  隐瞒了意图╮
    2020-11-28 13:40

    This is the syntax for creating an instance of anonymous class that extends Handler. This is part of Java.

提交回复
热议问题