(Revising Listing 21.1) Revise the GenericStack class in Listing 21.1 to imple- ment it using an array rather than an ArrayList. You should check the array size before adding a new element to the stack. If the array is full, create a new array that doubles the current array size and copy the elements from the current array to the new array. Problem 21.3 asks you to write a generic method that removes duplicate items from an ArrayList. Write your method in a new class called Utilities. Please include a main method for this class that tests your method. Think carefully about the way you test your program. Developing a good test plan is as important as developing the code itself. Obviously, you should show that your generic method works for different types of objects, i.e. ArrayLists or arrays of Integer, Strings, FacebookUsers, etc. You should also test any unusual cases you can think of: what if the ArrayList or array is empty? what if it contains only one item? what if your removeDuplicates method is passed an ArrayList in which every item is identical? etc.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

please i neeed a java program

 

(Revising Listing 21.1) Revise the GenericStack class in Listing 21.1 to imple-
ment it using an array rather than an ArrayList. You should check the array size
before adding a new element to the stack. If the array is full, create a new array
that doubles the current array size and copy the elements from the current array to
the new array.
Problem 21.3 asks you to write a generic method that removes duplicate items from an ArrayList.
Write your method in a new class called Utilities. Please include a main method for this class that
tests your method. Think carefully about the way you test your program. Developing a good test plan
is as important as developing the code itself. Obviously, you should show that your generic method
works for different types of objects, i.e. ArrayLists or arrays of Integer, Strings, FacebookUsers, etc.
You should also test any unusual cases you can think of: what if the ArrayList or array is empty? what
if it contains only one item? what if your removeDuplicates method is passed an ArrayList in which
every item is identical? etc.
Transcribed Image Text:(Revising Listing 21.1) Revise the GenericStack class in Listing 21.1 to imple- ment it using an array rather than an ArrayList. You should check the array size before adding a new element to the stack. If the array is full, create a new array that doubles the current array size and copy the elements from the current array to the new array. Problem 21.3 asks you to write a generic method that removes duplicate items from an ArrayList. Write your method in a new class called Utilities. Please include a main method for this class that tests your method. Think carefully about the way you test your program. Developing a good test plan is as important as developing the code itself. Obviously, you should show that your generic method works for different types of objects, i.e. ArrayLists or arrays of Integer, Strings, FacebookUsers, etc. You should also test any unusual cases you can think of: what if the ArrayList or array is empty? what if it contains only one item? what if your removeDuplicates method is passed an ArrayList in which every item is identical? etc.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education