Respuesta :
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;
}
See attachment for full program that includes the main method
def reverseString(str):
y = str[::-1]
return y
print(reverseString("ABCDE"))
The code is written in python. A function name reverseString is declared. The function takes an argument str.
Then a variable named y is used to store the reverse of our argument string.
The keyword return is used to output the reversed string.
Finally, the function is called with a print statement.
The bolded portion of the code are keywords in python.
read more: https://brainly.com/question/15071835?referrer=searchResults