Hey, complete beginner programmer here, learnt about user input today and decided to mess about. All codes with integers and doubles worked perfectly, but I'm stuck with string. It shows up as incorrect when I write in "Yes", with or without brackets.
I'm guessing there's something more to than just assigning "Yes" to the string ans variable.
Any help would be appreciated!
package MessingAbout; import java.util.Scanner; public class BlueSky { public static void main(String[] args){ Scanner rocky = new Scanner(System.in); String que, ans; ans = "Yes"; System.out.println("Is the sky blue?"); que = rocky.nextLine(); if (que == ans) { System.out.println("Correct!"); } else { System.out.println("Incorrect!"); } } }