Collections

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Collections as PDF for free.

More details

  • Words: 200
  • Pages: 7
The Java Collection Framework z

A unified architecture for representing and manipulating collections – – –

z

Interfaces Implementations Algorithms

Advantages – – – –

It reduces programming effort It increases program speed and quality It allows interoperability among unrelated APIs It fosters software reuse

Interfaces z

Collection –

z

Set –

z

cannot contain duplicate elements

List –

z

general interface

ordered collection

SortedSet –

maintains its elements in ascending order

Object Ordering z

Implement Comparable interface – –

z

List –

z

provides a natural ordering allows objects of that class to be sorted automatically could be sorted in the natural orderering by method Collections.sort(List l)

SortedSet –

all objects sorted according to the natural ordering

Implementation z

SortedSet –

z

TreeSet

List – – – –

ArrayList LinkedList Vector etc.

Comparable interface z

Source code public interface Comparable { public int compareTo(Object ob); }

z

Method compareTo returns negative – ob is less than this object zero – ob is equal to this object possitive – ob is greater than this object

Collection interface

For more information z

Documentation of the Collection Framework http://java.sun.com/j2se/1.4.2/docs/guide/collections/index.html – –

z

Tutorial API Specification

Introduction to the Collection Framework http://java.sun.com/developer/ onlineTraining/collections/Collection.html

Related Documents

Collections
October 2019 22
Collections
November 2019 33
Collections
November 2019 25
Home Collections
June 2020 8
My Collections
November 2019 21
Collections Questions
November 2019 13