Passing code as function arguments

后端 未结 6 1538
星月不相逢
星月不相逢 2021-01-23 22:56

I was reading a textbook and I was wondering how come the argument we pass to the function is neither a primitive or an user-defined instance of a class.

SwingU         


        
6条回答
  •  执笔经年
    2021-01-23 23:20

    This called anonymous class, where you define a class for a single use and do not provide it a name.

    To understand them better, refer to this tutorial: http://docs.oracle.com/javase/tutorial/java/javaOO/anonymousclasses.html

提交回复
热议问题