Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ReverseTester.java : import java.util.ArrayList; /** This program demonstrates reversing an arraylist */ public class ReverseTester { public static void main(String[] args) { ArrayList a =
ReverseTester.java :
import java.util.ArrayList; /** This program demonstrates reversing an arraylist */ public class ReverseTester { public static void main(String[] args) { ArrayLista = new ArrayList(); a.add("apple"); a.add("orange"); a.add("pear"); a.add("banana"); ArrayList b = ArrayListUtil.reverse(a); System.out.println("Original: " + a); System.out.println("Expected: [apple, orange, pear, banana]"); System.out.println("Reversed: " + b); System.out.println("Expected: [banana, pear, orange, apple]"); } }
ReverseTester2.java :
import java.util.ArrayList; /** This program demonstrates reversing an arraylist */ public class ReverseTester { public static void main(String[] args) { ArrayListSuppose you are implementing a utility class, ArrayListutil, in which you provide some utility methods to apply on ArrayLists with various types. Provide a static method that reverses the clements of a gencric ArrayList. Provide anothcr static mcthod that rcturns thc reversc of a gcncric ArrayList, without modifying thc original lista = new ArrayList(); a.add("apple"); a.add("orange"); a.add("pear"); a.add("banana"); ArrayListUtil.reverse(a); System.out.println("Reversed: " + a); System.out.println("Expected: [banana, pear, orange, apple]"); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started