Advanced Java Programming - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Advanced Java Programming

Description:

Title: CS 195 Course Outline & Introduction to Java Author: nwang Last modified by: nwang Created Date: 5/5/2000 9:02:18 PM Document presentation format – PowerPoint PPT presentation

Number of Views:128
Avg rating:3.0/5.0
Slides: 22
Provided by: nwa86
Category:

less

Transcript and Presenter's Notes

Title: Advanced Java Programming


1
Advanced Java Programming
  • CSS446
  • Spring 2014
  • Nan Wang

2
Chapter Goals
  • Java Collection Framework
  • LinkedList
  • Set
  • Map

3
Collection
  • When you need to organize multiple objects in
    your program, you can place them into a
    collection.
  • A collection groups together elements and allows
    them to be retrieved later.
  • ArrayList

4
Java Collections Framework
  • A hierarchy of interface types and classes for
    collecting objects. Each interface type is
    implemented by one or more classes.

5
(No Transcript)
6
List
  • a list is a collection that remembers the order
    of its elements.

7
ArrayList
  • The ArrayList class implements the List
    interface.
  • An ArrayList is simply a class containing an
    array that is expanded as needed.
  • If you are not concerned about efficiency, you
    can use the ArrayList class whenever you need to
    collect objects. However, several common
    operations are inefficient with array lists. In
    particular, if an element is added or removed,
    the elements at larger positions must be moved.

8
Insertion and Deletion of ArrayList
element
element
element
element
9
Set
  • Set is an unordered collection of unique
    elements.
  • Because a set does not track the order of the
    elements, so the operations of finding, adding
    and removing are more efficient.

10
Stack
  • A stack remembers the order of its elements, but
    it does not allow you to insert elements in every
    position.
  • You can add and remove elements only at the top.

11
Queue
  • In a queue, you add items to one end (the tail)
    and remove them from the other end (the head).
  • A priority queue is an unordered collection that
    has an efficient operation for removing the
    element with the highest priority. (reading
    assignments)

front
rear
rear
rear
rear
rear
12
Map
  • A map keeps associations between key and value
    objects.

13
LinkedList
  • A linked list uses a sequence of nodes.
  • A node is an object that stores an element and
    references to the neighboring nodes in the
    sequence

14
LinkedList Insert and delete
15
LinkedList Class
  • It is a generic class, that you specify the type
    of the list elements in angle brackets.

16
List Iterators
  • List iterators are used to access elements inside
    a linked list.
  • you should think of the iterator as pointing
    between two elements, just as the cursor in a
    word processor points between two characters

17
List Iterators
  • Obtain a list iterator with the listIterator() of
    the LinkedList class.

18
(No Transcript)
19
(No Transcript)
20
Review Questions
21
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com