You can use a loop to check every character position and catch the IndexOutOfBoundsException when you pass the last character. But why?
public int slowLength(String myString) {
int i = 0;
try {
while (true) {
myString.charAt(i);
i++;
}
} catch (IndexOutOfBoundsException e) {
return i;
}
}
Note: This is very bad programming practice and very inefficient.
You can use reflection to examine the internal variables in the String class, specifically count.