1

I am tring to do if() for String[] args to check if the string is between 1 to 5

here is my code:

public static void main(String[] args) {
    System.out.println(args[0] == "1" || args[0] == "2" || args[0] == "3" || args[0] == "4" || args[0] == "5");
}

the code is returning false when I type anything.

thx for help

Itay Sharon
  • 49
  • 1
  • 9
  • 2
    You should use `.equals` and not `==` to compare Strings. – Tunaki Apr 03 '16 at 12:58
  • Well, to check if a string contains numeric 1 - 15 from args[], you might need to define a separate function. –  Apr 03 '16 at 13:13

0 Answers0