• 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

Collection

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I would like to know how much in depth we are supposed to know of collection topic. I know the different interface in it and the implication of them. But I am confused after solving Dan's test of chapter 11. Do we need to know the different methods for each inteface, iterator methods and all in it.

Thanks.
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to know which data structure is or not suitable for a given situation.

The most common methods should be known as well, like entrySet(), keySet(), iteration() etc.

Nick
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody!
I'm thinking .
Can i know about collections in Data Structure.And the implement methods in that collections.thank you before!
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kalyani Marathe wrote:Hi all,

I would like to know how much in depth we are supposed to know of collection topic. I know the different interface in it and the implication of them. But I am confused after solving Dan's test of chapter 11. Do we need to know the different methods for each inteface, iterator methods and all in it.



Hi,

I learned all methods which are talked about in the Kathy/Bert book. There are quite some, but most of the time self explaining.
For example I learned about the Map method Set keySet(), but not about the Map method Set entrySet(), where Set is the return type.
Offtopic question:
What happens in the entrySet, if we have duplicate values?

And btw. who is Dan?

cheers
Bob

Edit: changed the post to clarify that Set is the return type.
 
Bob Wheeler
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

dang khac luan wrote:Hi everybody!
I'm thinking .
Can i know about collections in Data Structure.And the implement methods in that collections.thank you before!


Hi,

check out this Java tutorial by Josh Bloch: Collections (The Java Tutorials)

cheers
Bob
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bob,

Just to correct you (I'm sure it was just a typo). keySet and entrySet are not in fact methods on Set, they are of course methods of Map which return a Set.

And to answer your question about duplicate values in the entrySet:
The entrySet returns a "Set<Map.Entry>". The "Map.Entry" instances are only considered equal if they have the same key and value. In a Map the keys are unique so two Map.Entry instances will never be considered equal therefore there are no duplicates. Obviously there can be more than one equivalent value in the Map which is why the "Map.values()" method returns a Collection and not a Set.
 
Bob Wheeler
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Beckett wrote:
Just to correct you (I'm sure it was just a typo). keySet and entrySet are not in fact methods on Set, they are of course methods of Map which return a Set.


I meant the return type, but I'll change my post to clarify that.

Paul Beckett wrote:
And to answer your question about duplicate values in the entrySet:
The entrySet returns a "Set<Map.Entry>". The "Map.Entry" instances are only considered equal if they have the same key and value. In a Map the keys are unique so two Map.Entry instances will never be considered equal therefore there are no duplicates. Obviously there can be more than one equivalent value in the Map which is why the "Map.values()" method returns a Collection and not a Set.


Very interesting. Map.Entry is a "nested" interface in the Map class and its equals method describes it all.

Thanks Paul for your fast help.
cheers
Bob
 
Warning! Way too comfortable! Do not sit! Try reading this tiny ad instead:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic