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,586
  • 4
  • 28
  • 57
Aikoku
  • 27
  • 6

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
  • 80,601
  • 10
  • 150
  • 186