帮看一段java代码,每一个属性对应的是什么
classCar{publicStringcolor=“red”;publicintdoors=4;publicintmpg=23;publicCar(Stringcol...
class Car {
public String color = “red”;
public int doors = 4;
public int mpg = 23;
public Car(String color, int doors, int mpg) {
this.color = color;
this.doors = doors;
this.mpg = mpg;
}
public void showColor() {
System.out.println(color);
}
}
this.color = color这里等号后面的color应该是public Car(String color, int doors, int mpg)这里的color吧?然而this后面的color是不是指上面的 public String color =”red“这里面的这个color呢?还是有其它含义 展开
public String color = “red”;
public int doors = 4;
public int mpg = 23;
public Car(String color, int doors, int mpg) {
this.color = color;
this.doors = doors;
this.mpg = mpg;
}
public void showColor() {
System.out.println(color);
}
}
this.color = color这里等号后面的color应该是public Car(String color, int doors, int mpg)这里的color吧?然而this后面的color是不是指上面的 public String color =”red“这里面的这个color呢?还是有其它含义 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询