Any ideas why I'm getting this error? Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 64 at java.lang.String.charAt(String.java:658) at ReverseString.main(ReverseString.java:8)
Don't make a new variable length.
Remind yourself of the normal format of a for loop to traverse an array:-
for (int i = 0; i < myArray.length; i++) ... and to do the same backwards:-
for (int i = myArray.length - 1; i >= 0; i--) ... I think you should always use those formats as a starting point for for statements, even if you have to change them later. In the case of a String write text.length() rather than myArray.length.
You will probably get faster execution if you don't print the characters individually; append them to a StringBuilder object and print that.