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

📄 staticinnerclassdemo.java

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

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

	public void show(){
		System.out.println("这是一辆"+ color +brand +"车,该车有");
		abs.introduce();
		engine.start();
	}
	private static class ABS{
		public void introduce(){
			System.out.println("ABS防死抱系统");
		}
	}
	
	static 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 StaticInnerClassDemo{
	public static void main(String arg[]){
		Car 奔驰 = new Car("奔驰","黑色");
		Car.Engine 劳斯来斯 = new Car.Engine("劳斯来斯",600);
//		Car.ABS abs = new Car.ABS();
		奔驰.show();
		劳斯来斯.start();
		
	}
}

⌨️ 快捷键说明

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