匿名类:只使用一次
使用代码如下:
class test{
public void prin(){
System.out.println("hello world");
}
}
public class Main {
public static void main(String args[]) {
// test t = new test(); 这里使用正常的输出
// t.prin();
new test().prin();//这里用匿名类
}
}
匿名类的使用
最新推荐文章于 2024-10-11 07:44:46 发布