Answer:
The method written in Java is as follows:
public static String reverseString(String str){
String result = "";
int lentt = str.length();
char[] strArray = str.toCharArray();
for (int i = lentt - 1; i >= 0; i--)
result+=strArray[i];
return result;
}
Explanation:
This defines the method
public static String reverseString(String str){
This initializes the result of the reversed string to an empty string
String result = "";
This calculates the length of the string
int lentt = str.length();
This converts the string to a char array
char[] strArray = str.toCharArray();
This iterates through the char array
for (int i = lentt - 1; i >= 0; i--)
This gets the reversed string
result+=strArray[i];
This returns the reversed string
return result;
}
<em>See attachment for full program that includes the main method</em>