Java Collections - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Java Collections

Description:

Collections are classes which store ... all collections have a similar interface so once you use one, using another is easy ... Collections: Disadvantages ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 9
Provided by: garyg4
Category:
Tags: collections | java

less

Transcript and Presenter's Notes

Title: Java Collections


1
Java Collections
  • Gary Greer

2
How Will You Store Data?
  • one of the big programming decisions is in how
    you will store data
  • often you will not know how much data you will
    need to store, so an array just wont cut it
  • also there is often a lot of programming that
    revolves around storing and retrieving data
  • Collections can solve these problems

3
What Are Collections?
  • Collections are classes which store information
  • may also be called containers
  • they are Java objects
  • can be used in programs by importing java.util.
  • they have been written by experts

This presentation refers a great deal to
information from Eckel, 2003.
4
Collections Advantages
  • no pre-defined limit on the size of the
    collection (as big as you want)
  • much of the programming is already done
  • they are generally fast and efficient
  • all collections have a similar interface so once
    you use one, using another is easy
  • you will save writing time

5
Collections Disadvantages
  • if you have a program where speed is crucial,
    collections may not be quick enough
  • a collection can contain only objects
  • if you need to store primitives (like integers)
    you need to wrap them in a wrapper class (like
    Integer)
  • a collection does not know what type of object it
    contains and the programmer needs to cast the
    object into the correct type

6
Collections 2 Basic Types
  • true collections provide places to hold
    individual elements
  • these can be lists or sets
  • examples are ArrayList and TreeSet
  • maps are special in that they hold keyelement
    pairs
  • imagine a structure for example which holds words
    and the associated definitions
  • an example is a TreeMap

7
Sounds Difficult!
  • well, it is not that difficult really
  • there is really minimal programming involved,
    although there are a few things to be learned
  • however, unlimited size and faster program
    writing are usually worth it

8
References
  • Eckel, B. (2003). Thinking in Java. Retrieved
    from www.BruceEckel.com
  • Sun MicroSystems (2005). Java APIs. Retrieved
    from http//java.sun.com/j2se/1.5.0/docs/api/index
    .html
Write a Comment
User Comments (0)
About PowerShow.com