Question: Java Lab Steps Exercise 1: Review of Array-Based Lists Create a project using the classes in this zip file (Links to an external site.)Links to

Java

Lab Steps

Exercise 1: Review of Array-Based Lists

Create a project using the classes in this zip file (Links to an external site.)Links to an external site. and name it "A Simple ArrayList Class." Compile it, run it, and review the code that is given carefully. This code tests the ArrayList class discussed in the lecture.

Exercise 2: Implementing an Array List

Modify the class ArrayList given in Exercise 1 by using expandable arrays. That is, if the list is full when an item is being added to this list, the elements will be moved to a larger array. The new array should have twice the size of the original array.

Exercise 3: Using an Array-Based List

Using the class ArrayList completed in the previous exercise, write a program to store 1,000 random numbers, each in the interval [0, 500]. The initial size of the array in the class should be set to 100. Print the numbers.

Exercise 4: Implementing a Bag Class

Create a class bag (multiset) that uses an expandable array to store the bag items. The item type must be a Java String type; that is, the bag will store strings of characters. The class should have the methods listed below. Create a main class to test your bag class and demonstrate each of these methods. This main class should fill a bag with the keywords of the Java language.

Bag(): default constructor

boolean isEmpty(): determines whether the bag is empty (still need it)

void print(): prints the bag elements (still need it)

int getLength(): returns the number of items in the bag (still need it for expansion)

void add(String item): adds an item to the bag

void removeOne(String item): removes item from the bag; only one occurrence of item should be removed.

.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!