Passing code as function arguments

后端 未结 6 1540
星月不相逢
星月不相逢 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:14

    Read about Anonymous Classes. This are treated as separate classes. If you compile your code and say the file name is Test.java. By compiling there will two class file Test.class and Test$1.class and if you have more inner classes you will have Test$2.class, Test$3.class and so on.

提交回复
热议问题