Your code cannot be compiled because in java character '
( single quote ) is used to mark one character. In order to define string you should use double quote "
.
In your case I believe that you wanted to check whether your string contains digits only and were confused with regular expression syntax you tried to use incorrectly.
You can either rewirte your if statement as following:
char c = str.charAt(i);
if(c>= '0' && c <= 9) {
or use pattern matching, e.g.
Pattern.compile("\\d+").matcher(str).matches()
In this case you even do not need to implement any loop.