localinnerclassdemo.java
来自「JAVA的一些基础教程」· Java 代码 · 共 39 行
JAVA
39 行
interface GPRS{
public void position();
}
class Car{
String brand;
String color;
GPRS tools;
public Car(String 牌子,String 颜色,final int miles){
brand = 牌子;
color = 颜色;
class GPRStool implements GPRS{
public void position(){
System.out.println("您的"+brand +"车已经行走了"+miles +"英里, 现在的位置是广州");
}
}
tools = new GPRStool();
}
public void getMiles(int miles){
System.out.println("您行走了"+ miles + "英里");
}
public void show(){
System.out.println("这是一辆"+ color +brand +"车");
tools.position();
}
}
public class LocalInnerClassDemo{
public static void main(String arg[]){
Car 捷达 = new Car("捷达","黑色",50000);
捷达.show();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?