I would like to make a conditional that I can receive a word like the number one or that the number 1 is entered directly.
Having a conditional like the following:
if ($var == "Uno" || @intval($var1) == 1){
echo "Picked 1";
}
In PHP, any possibility of error in the variable or function that has a @ before it is omitted, as in the example above.
Returning to Java , if the user types 1 is valid for the first condition, "1"!="One" , then the process continues, until you reach parseInt (var) == 1 .
The problem is when instead of 1 you type one , for the first condition the code is valid, "One" == "One" strong>, but for parseInt ("One") the code is not valid and that's where the error is.
What I have is the following, but it is clear that it is incorrect, since @ is not valid in Java.
String var;
if (var == "Uno" || @parseInt(var) == 1){
System.out.println("Picked 1");
}
What would the code look like in Java? I am totally new in the language.