提高代码复用性
程序员文章站
2022-04-15 10:04:54
...
提高代码复用性
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(); } }