• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Quick Intro to Java Collections
 

Quick Intro to Java Collections

on

  • 811 views

 

Statistics

Views

Total Views
811
Views on SlideShare
811
Embed Views
0

Actions

Likes
0
Downloads
23
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Quick Intro to Java Collections Quick Intro to Java Collections Presentation Transcript

    • Quick  Intro  to  Java  Collec2ons   Jussi  Pohjolainen   Tampere  University  of  Applied  Sciences  
    • Intro  •  Java  Collec2on  Framework  is  a  set  of  classes   and  interfaces  to  implement  data  structures  •  When  array  is  not  enough..  J  •  Lot  of  classes  and  interfaces   –  hFp://upload.wikimedia.org/wikipedia/ commons/4/41/Collec2on_Classes.jpg  
    • Core  Collec2on  Interfaces  
    • Collec2on  Interface  •  Basic  parts  of  all  collec2ons  •  add(),  remove(),  toArray(),  contains()  •  Collec2on  is  generic  
    • Three  main  type  of  Collec2on  •  List   –  Always  ordered,  may  contain  duplicates,  like  an   array  •  Set   –  Cannot  contain  duplicate  •  Map     –  Key  –  value  pairs,  random  access  to  keys  
    • List  •  List  interface  has  two  concrete  classes   –  ArrayList  –  implementa2on  uses  dynamically   resized  arrays   –  LinkedList  –  double-­‐linked  list  
    • Set  •  Set  can’t  have  duplicates  •  Couple  concrete  classes   –  HashSet     –  TreeSet  –  sorted  elements!  
    • Map  •  Key  value  pairs  •  Couple  concrete  classes     –  HashMap     –  TreeMap  -­‐  sorted  
    • How  to  iterate?  •  Use  an  iterator!    Iterator i = someCollection.iterator();while(i.hasNext()) { System.out.println(i.next());}