Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Collection

 
Venu Babu Ravi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vijayakumar Rengaraj
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic