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!");
    }


}

I am using IntelliJ although I get the error message: Error: Could not find or load main class World Caused by: java.lang.ClassNotFoundException: World

1

There are 1 best solutions below

0
On

Check if your class is in a package. Without a package your code wont run. Otherwise if you have other classes containing main methods it wont work as you cant have more than 1 main method