Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions

Question

What is the purpose of interim financial reporting?

Answered: 1 week ago

Question

The maximum number of leaves in a binary tree of depth d is 2 d

Answered: 1 week ago