An Immutable String
You can safely give this answer without looking into mysteryMethod().
Once a String has been constructed,
you know what it is.
charAt()
The charAt(int index) method of String
returns the character at the specified index.
Index 0 is the first character of the String,
and the last character is at index length()-1.
The method returns a value of type char.
For example,
String eg = "An Immutable String"; char ch0 = eg.charAt(0); // ch0 gets 'A' char ch1 = eg.charAt(1); // ch1 gets 'n' char ch5 = eg.charAt(5); // ch5 gets 'm' char ch18 = eg.charAt( eg.length()-1 ); // ch18 gets 'g' char ch17 = eg.charAt( eg.length()-2 ); // ch17 gets 'n'
(Design Question: ) How could you make a string that contains the characters of another string in reverse order?