canner sc = new Scanner(System.in) ;
String y = "" ;
String z = "a" ;
System.out.print("Type a number : ");
y = sc.next();
System.out.println( y + " == " +z+ " :");
System.out.println( y == z);
The result printout :
Type a number : a
a == a : false
However, my expectation is TRUE.
Yes, it seems so. But in Java You cannot use == for comparing strings, You should use equals
Scanner sc = new Scanner(System.in) ;
System.out.println("Type a character a : ");
String y = sc.nextLine();
String z = “a” ;