java吧 关注:1,236,811贴子:12,707,870
  • 0回复贴,共1

java新手求教

只看楼主收藏回复

为什么控制台输出的结果会不同?
public class Car{
int speed;
public void raiseSpeed(){
speed=50;
}
}
public class Test{
public static void main (Strings [] args){
Car MyCar = new Car();
System.out.println(MyCar.speed);
}
}
public class Test{
public static void main (Strings [] args){
Car MyCar = new Car();
MyCar.raiseSpeed();
System.out.println(MyCar.speed);
}
}


IP属地:陕西来自Android客户端1楼2016-05-18 21:19回复