有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java中找不到class命令的错误消息

import java.util.*;
class Example {
    public static void main(String args[]) {
       Scanner input = new Scanner(System.in);
       System.out.print("number of rooms:");
       int rooms = input.nextInt();
       int count = 0;
       for(int i = 0; i < rooms; i++) {
           System.out.print("room capacity-q:");
           int q = input.nextInt();
           System.out.print("current space of the room-p:");
           int p = input.nextInt();
           if ((q - p) >= 2) {
               count += 1;
           }
       }
       System.out.println("no.rooms for thusitha & chamod is:"+count);
    }
}

我收到一个名为“找不到类”的错误。我想知道原因是什么


共 (1) 个答案

  1. # 1 楼答案

    代码运行良好;不会导致这样的错误。 如果你能提供你得到的错误的细节,那就更好了

    虽然我看不出有什么地方不对。 你的代码中没有美感或打字错误。 它给出了一个关于输入扫描仪未关闭的警告;暂时可以忽略这一点