I'm having trouble with a switch statement

Scanner scan = new Scanner (System.in);     
        char chars = scan.nextLine();
        
        System.out.println("A Andorra\n" +
                "B Belgium\n" +
                "F Finland\n" +
                "M Malta\n" +
                "S Slovenia\n\n" +
                "Choose a country from menu above:\n" + chars);
        
        switch (chars)
        {
            case 'A':
                System.out.println("You chose \"Andorra\"");
                break;
            case 'B':
                System.out.println("You chose \"Belgium\"");
                break;
            case 'F':
                System.out.println("You chose \"Finland\"");
                break;
            case 'M':
                System.out.println("You chose \"Malta\"");
                break;
            case 'S':
                System.out.println("You chose \"Slovenia\"");
                break;
            default:
                System.out.println("That country is not on the list\n");
                
        }

but i'm getting an error saying that the char is an incompatable type. i'm new to java and don't understand y

Because you are calling nextLine() on the scanner and that method returns a String, not a char

char chars = scan.nextLine();

Capture a String instead and use String.charAt(0) to get the first char.

String input = scan.nextLine();
char choice = input.charAt(0);
switch (choice) { ...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.