gudii9
asked on
collection questions
Hi,
i have below collection questions. please advise
why array list implements RandomAccess and cloneable serializeable
why RandomAccess in marker interface and how is interface useful without methods
which collection is good for retrieval,insertion, deletion etc
i have below collection questions. please advise
why array list implements RandomAccess and cloneable serializeable
why RandomAccess in marker interface and how is interface useful without methods
which collection is good for retrieval,insertion, deletion etc
ASKER
b is the list "20, 10, null". (b has value 20, with m_Next set to a that has value 10).
i did not understand above line. please advise
so this is example which is not implementing random access so it is slow right?
b has a so to reach a through b requires more loop like that to go to deeper elements like 100 deep. so without randome access it is slow right.
please advise my understanding is correct on what you mentioned
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Like it says, the idea is you can mark a collection as being quick to access things in a random order.
So you can get to element 100 as quickly as you can reach element 2.
So when would that not be true? Here's another List implementation that uses a simple linked list:
Open in new window
Open in new window
I hope you can see that
b is the list "20, 10, null". (b has value 20, with m_Next set to a that has value 10).
To look up the values in this list the code would be:
Open in new window
Since that requires a loop, it will be slower for the 100th element than the 1st, so not random access.
Make sense?
Doug