As you might be able to see, i am a complete newbie to java. but i'm trying to make a rock-paper-scissor game. But when i pass the input to the method, it doesn't return true, while the input is "rock". i checked.
What should happen, is that as the input is rock, true gets returned. now it just returns false.
thanks in advance!
import java.util.Scanner;
public class Game{
static Boolean validInput(String input){
if("rock" == input){
return true;
}
else{
return false;
}
}
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String choice;
choice = input.nextLine();
if(validInput(choice)){
System.out.println(choice + " is valid input");
}else{
System.out.println(choice + " is not valid...");
}
}
}