Question: The Java API contains two important structures for managing array-based lists. One, the Vector , manages lists in a thread-safe manner (for concurrency) and the

The Java API contains two important structures for managing array-based lists. One, the Vector, manages lists in a thread-safe manner (for concurrency) and the other, the newer ArrayList, does the same but without the overhead required for multiprocessing thread-safety. How do these implementations compare with our own? Look at the online Java API documentation for both and post the following five details, for each of them, into a text file, attach it back to this assignment and send it in (you should have five methods listed for the Vector and another five listed for the ArrayList in a tabular arrangement):

Activity:

Find the methods in Vector and ArrayList that most closely match our own List methods of:

Book's ArrayListClass Java's Vector Java's ArrayList ------------------------- ------------------------- ------------------------- 1. isEmpty 2. retrieveAt 3. seqSearch 4. removeAt 5. listSize

Now be careful! Compare our methods not necessarily by their names, but by their function, parameters and return types.

ArrayListClass // Not complete UML

--------------------------------------

#length: int

#maxSize: int

#list: DataElement[ ]

--------------------------------------

...

+isEmpty(): boolean // Determines whether if list is empty. Returns true if list is empty

+retrieveAt (int) : DataElement // Retrieves the element from the list at the position specified by location. A copy of the element at the position specified by location is returned.

+seqSearch (DataElement): int // Determines whether searchItem is in the list. returns location on where it is found, otherwise returns -1.

+removeAt(int): void // Removes item from the list at the position specified by location.

The list element at list[location] is removed/length decremented by 1

+listSize(): int // returns the number of elements in the list. Returns the value of length

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!