-1
import java.util.Scanner;
public class World {

    public static void main(String[] args) {
        Scanner scnr = new Scanner(System.in);
        System.out.println("Hello. What is your name? ");
        String input = scnr.next();
        System.out.println("It's nice to meet you, " + input + ". How old are you?");
        String age = scnr.next();
        System.out.println("I see that you are still quite young at only " + age + ".");
        System.out.println("Where do you live? ");
        String city = scnr.next();
        System.out.println("Wow! I've always wanted to go to " + city + ". Thanks for chatting with me. Bye!");
    }


}

我正在使用 IntelliJ,尽管我收到错误消息:错误:无法找到或加载主类 World 原因:java.lang.ClassNotFoundException:World

4

1 回答 1

-1

检查您的课程是否在一个包中。如果没有包,您的代码将无法运行。否则,如果您有其他包含主要方法的类,它将无法工作,因为您不能拥有超过 1 个主要方法

于 2021-05-25T18:39:01.737 回答