[Solved]4 Rewrite Reverse Method Fig 146 Reverse String Placing Last Character Beginning Reverse S Q37037149

4. Rewrite the reverse method in Fig. 14.6. Reverse a string by placing its last character at the beginning of the reverse of the substring that contains the entire string except for its last character. Test your program 1 class Recursion4 3 4 5 6 public static void main(String[1 args) System.out.println (reverse()) System.out. printIn(reverse(“A”)); System.out.println (reverse ( “ABCDEF”)); /I null string 1 1-char string // multi-char 8 9 10 public static String reverse (String s) 12 13 14 15 16 h if (s.length() 1) return s; return reverse (s.substring (1, s.length)) s.substring (0, ); Figure 14.6 Show transcribed image text 4. Rewrite the reverse method in Fig. 14.6. Reverse a string by placing its last character at the beginning of the reverse of the substring that contains the entire string except for its last character. Test your program 1 class Recursion4 3 4 5 6 public static void main(String[1 args) System.out.println (reverse()) System.out. printIn(reverse(“A”)); System.out.println (reverse ( “ABCDEF”)); /I null string 1 1-char string // multi-char 8 9 10 public static String reverse (String s) 12 13 14 15 16 h if (s.length() 1) return s; return reverse (s.substring (1, s.length)) s.substring (0, ); Figure 14.6
Expert Answer
Answer to 4. Rewrite the reverse method in Fig. 14.6. Reverse a string by placing its last character at the beginning of the rever… . . .
OR

