I'm writing a method to find the upper case letters in a given string. I have this
public static String FindUpperCase (String x){
for (int i = x.length(); i>=0; i--){
if (Character.isUpperCase(x.charAt(i))){
return x.substring(i); }
}
But I'm getting an error thats telling me I must return a string. When I look up on the API what substring does it tells me that it returns a string that is a subset of the other string...which means I am returning a string, right? I was told that it was because I am returning a string within the loop and that's not the same thing but I'm a little confused by what this means because isn't the loop in the method? Does anyone know what I'm doing wrong or how I can fix this?