@@ -0,0 +1,1127 @@
+import java.util.Arrays;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0Apublic class StringReversalAnswer %7B%0A    %0A    public static void main(String%5B%5D args) %7B%0A        final String input = %22how to reverse a string%22;%0A        %0A        System.out.println(reverse(input));%0A        System.out.println(reverse2(input));%0A    %7D%0A    %0A    private static String reverse(final String input) %7B%0A        return reverse(new LinkedList%3CString%3E(Arrays.asList(input.split(%22%22))));%0A    %7D%0A    %0A    private static String reverse(final List%3CString%3E input) %7B%0A        String output = %22%22;%0A        %0A        if (!input.isEmpty()) %7B%0A            output = input.remove(0);%0A            return reverse(input) + output;%0A        %7D else %7B%0A           return %22%22;%0A        %7D%0A    %7D%0A    %0A    private static String reverse2(final String input) %7B%0A        String output = %22%22;%0A        %0A        if (input.length() %3E 0) %7B%0A            final String%5B%5D parts = input.split(%22%22);%0A            for (int i = parts.length - 1; i %3E= 0; i--) %7B%0A                output += parts%5Bi%5D;%0A            %7D%0A            %0A            return output;%0A        %7D%0A        %0A        return %22%22;%0A    %7D%0A    %0A%7D

answer to lab 2