Answered step by step
Verified Expert Solution
Link Copied!

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 =

image text in transcribed

ReverseTester.java :

import java.util.ArrayList; /** This program demonstrates reversing an arraylist */ public class ReverseTester { public static void main(String[] args) { ArrayList a = 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) { ArrayList a = 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]"); } }
Suppose 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 list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions