class robot{
String status;
double speed;
double temperature;void checktemperature(){
if(temperature>600){
speed=5;
status="return home!";
}
}
void showattitude(){
System.out.println("status:"+status);
System.out.println("speed:"+speed);
System.out.println("temperature"+temperature);
}public static void main(String[] args){
robot henry=new robot();
henry.status="exploring";
henry.speed=3.33;
henry.temperature=300.2;henry.showattitude();
System.out.println("increase his temperature to 700.333");
henry.showattitude();
System.out.println("check his temperature");
henry.checktemperature();
henry.showattitude();
}
}为什么运行不了呢?

解决方案 »

  1.   

    编译都通不过更别说运行了
    class robot改为  public class Robot并且保存的文件名为   Robot.java
      

  2.   

    可以运行 结果是
    status:exploring
    speed:3.33
    temperature300.2
    increase his temperature to 700.333
    status:exploring
    speed:3.33
    temperature300.2
    check his temperature
    status:exploring
    speed:3.33
    temperature300.2
      

  3.   

    public class都没有你们是如何运行的????
      

  4.   

    谁告诉你一定要加 public的 默认修饰符也可以
      

  5.   

    一个文件最多只有一个public class也就是可以有/没有