• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regarding Collection

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic