class Car_Test1 {
public static void main(String[] args) {
//Car c1 = new Car();
//c1.color = "红色";
//c1.num = 8;
//c1.run();
//method(c1);
method(new Car()); //匿名调用
//Car c2 = new Car();
//method(c2);
method(new Car()); //匿名调用
}
public static void method(Car cc) {
cc.color = "红色";
cc.num = 8;
cc.run();
}
}
/*
汽车
属性:颜色(color)轮胎数(num)
*/
class Car {
String color;
int num;
public void run() {
System.out.println(color+"..."+num);
}
}
|
|