0
for (char c : str.toCharArray()) {
        if (!Character.isDigit(c)) {
            return false;
        }
    }

Dont understand what mean condition of foor loop. How write this part of code in If/else form. Thank you.

Dima
  • 8,520
  • 4
  • 26
  • 56
Aikoku
  • 27
  • 5

1 Answers1

1

The code means for each character in the string, if it's not a digit, return false. You can't write it purely in if/else form, as you need a loop to visit each character in the string.

Ernest Friedman-Hill
  • 79,064
  • 10
  • 147
  • 183