为什么控制台输出的结果会不同?
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);
}
}
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);
}
}