Improve code reusability

Here is the programming house jb51 CC collects and arranges code fragments through the network.

Programming house Xiaobian now shares it with you and gives you a reference.

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();
		
	}
}

The above is all the code content collected by the programming home (jb51. CC). I hope this article can help you solve the program development problems you encounter.

If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>