关于程序员:提高代码复用性

35次阅读

共计 276 个字符,预计需要花费 1 分钟才能阅读完成。

package car;

public class Car {

String color;
int number;
 
void run(){System.out.println(color+"::"+number);
}

}

class carDemo
{

public static void main(String[] args)
{Car c = new Car();
 
    show(c);
}
/*
 * 封装性能
 * Car c = new Car();
 * Car c1 = new Car();
 * */
public static void show(Car cc)
{
    cc.color = "red";
    cc.number = 4;
    cc.run();}

}

正文完
 0