*
The moose likes Beginning Java and the fly likes Regarding Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regarding Collection" Watch "Regarding Collection" New topic
Author

Regarding Collection

Venu Babu Ravi
Greenhorn

Joined: Jun 08, 2010
Posts: 16
In a Collection there are ten numbers from 1 to 10. After that i have retrived 9 numbers randomly.Can any one help me what is number avilable in the collection


venubabu.ravi
Vijayakumar Rengaraj
Greenhorn

Joined: Jun 09, 2010
Posts: 5
Venu Babu Ravi wrote:In a Collection there are ten numbers from 1 to 10. After that i have retrived 9 numbers randomly.Can any one help me what is number avilable in the collection


Welcome to Javaranch

The content of the collection will not change with respect to the retrieval, You can get the elements of the collection based on the position(in case of List) any any time.
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
Vijayakumar Rengaraj wrote:The content of the collection will not change with respect to the retrieval, You can get the elements of the collection based on the position(in case of List) any any time.

Arent Stacks and Queues also collections? In that case it's requestet that the contents change (push/pop etc.).

As for the original question: I don't understand what you're asking. You have a collection with ten objects in it, and then some randomly numbers ... how do they fit in there? Can you phrase the question again?


Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

@Peter: If the numbers were retrieved randomly, odds are it isn't a stack or queue.

@Venu: It depends on how you're retrieving them: if you're removing them as you retrieve them, it's easy. Otherwise you'd need to keep track of which numbers you've retrieved, like by removing them from a map, or using a bitmap, or toggling a flag, or... etc. There would be quite a few ways of implementing this.
 
wood burning stoves
 
subject: Regarding Collection
 
Similar Threads
How to convert xml to pdf form in java
Happy New Year! Welcome to our new forums!
Prime numbers selected at random
difference betwen Collection and Collections
Collection Framework