如图,这是一串测试java图形化窗口的代码
目的是想监听按钮点击发送反馈
但是看不懂第11行中的 new test().creat()
这里在main方法写对public class进行new 后面加上的.creat()是什么意思?(看不懂 11行的 new test().creat() )
程序运行没有问题
目的是想监听按钮点击发送反馈
但是看不懂第11行中的 new test().creat()
这里在main方法写对public class进行new 后面加上的.creat()是什么意思?(看不懂 11行的 new test().creat() )
程序运行没有问题
new test().creat()
意思是创建test类的一个对象,并调用类中的creat方法
new test()是匿名对象即没有名字的对象。
等价于:
test t=new test();
t.creat();
你的代码一步完成test类对象创建并且调用create 方法。
不理解,可以改为上述代码,都是一样的