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


}

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

Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129
vadose
  • 1
  • 1
  • 2
    I suspect that you didn't name the file: `World.java` (case-sensitive) so the class that should be tied to the file is not found. – Nir Alfasi May 25 '21 at 17:52

1 Answers1

-1

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

Hussaini
  • 1
  • 2