⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 instanceinnerclassdemo.java

📁 JAVA的一些基础教程
💻 JAVA
字号:
class Car{
	String brand;
	String color;	
	static String type = "越野车";
	Engine engine;

	public Car(String brand,String color){
		this.brand = brand;
		this.color = color;
		engine = new Engine("电喷",500);
	}

	public void show(){
		System.out.println("这是一辆"+ color +brand +"车,启动该车");
		engine.start();
	}
	
	class Engine{
		String type;
		int power;
		public Engine(String type, int power){
			this.type = type;
			this.power = power;
		}
		public void start(){
			System.out.println(type + " 引擎启动了");
			System.out.println("车的颜色是" + color);
		}
	}
}

public class InstanceInnerClassDemo{
	public static void main(String arg[]){
		Car 捷达 = new Car("捷达","黑色");
		Car.Engine 大众 = 捷达.new Engine("大众",600);
		捷达.show();
		大众.start();
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -