Quantcast
Channel: If else statement with a substring - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Sergey Kalinichenko for If else statement with a substring

$
0
0

The way you check a single character to be digit is not with Integer.parseInt (that one returns, an int, not a boolean). You use Character.isDigit instead:

else if (strPos.length() > 4 && Character.isDigit(strPos.charAt(4)))

Note that it's checking the character at index 4, which is the fifth character (the initial character is at index zero, not one).


Viewing all articles
Browse latest Browse all 2

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>