Nie można uzyskać instrukcji if, jeśli ma działać w Javie
Ok, próbuję zrobić to proste, ale to nie zadziała. Jestem początkującym w Javie i chciałbym pomóc. Za każdym razem, gdy uruchamiam poniższy kod, otrzymuję dane wyjścioweTo nie jest poprawna opcja. Co ja robię źle?
<code> package test; import java.util.Scanner; public class options { public void options() { Scanner scnr = new Scanner(System.in); String slctn; System.out.println("What would you like to do?"); System.out.println("a) Travel the expedition"); System.out.println("b) Learn more about the expedition"); slctn = scnr.nextLine(); if (slctn == "a"){ travel exeTravel = new travel(); exeTravel.travel(); }else if (slctn=="b"){ learn exeLearn = new learn(); exeLearn.learn(); }else{ System.out.println("That is not a valid option"); } } } </code>