Write a recursive method that takes a String parameter and prints out the characters of the string in reverse order.

What will be an ideal response?



public static void reverse(String s)
{
if (s.length() == 0)
return;
char lastChar = s.charAt(s.length() – 1);
System.out.print(lastChar);
reverse(s.substring(0, s.length() – 1));
}

Computer Science & Information Technology

You might also like to view...

Which of the following statements produces the same results as the statement:

std::copy(v1.begin(), v1.end(), v2.begin()); if v1 and v2 are both 10-element vectors? a. std::copy_backward(v1.begin(), v1.end(), v2.begin()); b. std::copy_backward(v2.begin(), v2.end(), v1.begin()); c. std::copy_backward(v1.begin(), v1.end(), v2.end()); d. std::copy_backward(v2.begin(), v2.end(), v1.end());

Computer Science & Information Technology

The Description property is optional for a field.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The XML document to be validated is called the ____________________ document.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

You cannot display parts of a PivotTable report on separate pages

Indicate whether the statement is true or false

Computer Science & Information Technology