| 1 | |
| 2 |
|
| 3 | public class Example {
|
| 4 |
|
| 5 | public static void main(String[] args) {
|
| 6 | String str = "Native Image is awesome";
|
| 7 | String reversed = reverseString(str);
|
| 8 | System.out.println("The reversed string is: " + reversed);
|
| 9 | }
|
| 10 |
|
| 11 | public static String reverseString(String str) {
|
| 12 | if (str.isEmpty())
|
| 13 | return str;
|
| 14 | return reverseString(str.substring(1)) + str.charAt(0);
|
| 15 | }
|
| 16 | }
|