What I want to do is simply read a input (Char/String , preferably char), its a single char and then print some outputs based on the inputs. My problems faced is that, if i convert my input 'choice' into a char, my error messages are:
Type mismatch: cannot convert from String to char Incompatible operand types char and String
any idea whats wrong? Thanks!
*If I leave it like this it just gives me "Invalid Choice"
import java.util.*;
public class P1 {
public static void main(String[] args) {
// Create a scanner
Scanner userInputScanner = new Scanner(System.in);
String choice = userInputScanner.nextLine();
System.out.println("Your choice is " + choice);
if ((choice == "A") || (choice == "a"))
System.out.println( " Action Movie Fan");
else if ((choice == "C") || (choice == "c"))
System.out.println( " Comedy movie fan ");
else if ((choice == "D") || (choice == "d"))
System.out.println(" Drama movie fan ");
else
System.out.println( "Invalid choice" );
}
}