import java.util.Scanner; import java.util.Random; public class Program { public static void main(String[] args){ Scanner keyboard = new Scanner(System.in); //scanner variable to get user input String option; System.out.println("Welcome!"); System.out.print("Do you want to play the game?"); option = keyboard.nextLine(); //storing input. if(option == "Yes"||option=="yes"){ System.out.println("Ok then!!! Lets play!"); } else{ System.out.println("\n"); System.out.println("Alright! bye!"); } } }
when i run this, i input "yes" into the command line and it goes straight to the "else" statement instead of running the code in the if statement. Can anyone help me and tell me what im doing wrong? Thanks a lot in advance!
