标签:rgs main pre 匿名 dem 区别 垃圾 car show
class Car { int num; String color; public void run() { System.out.println("汽车行驶中"); } } class Demo2 { public static void main(String[] args) { //int a; //System.out.println(a);//a尚未初始化 局部变量 //匿名对象‘ //new Car().num = 6;//匿名对象只能使用一次,使用结束就被回收 //new Car().color = "黑色"; //Car baoma = new Car(); //System.out.println(baoma.num+" " + baoma.color);//0 null //System.out.println(baoma.color); Car benchi = new Car(); //show(benchi); show(new Car()); } public static void show(Car car) { car.run(); } }
标签:rgs main pre 匿名 dem 区别 垃圾 car show
原文地址:https://www.cnblogs.com/bgwhite/p/9375501.html