George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 8.

Slides:



Advertisements
Similar presentations
Introduction to Computation and Problem Solving Class 32: The Java® Collections Framework Prof. Steven R. Lerman and Dr. V. Judson Harward.
Advertisements

Transparency No. 1 Java Collection API : Built-in Data Structures for Java.
Java Collections Framework COMP53 Oct 24, Collections Framework A unified architecture for representing and manipulating collections Allows collections.
CSci 143 Sets & Maps Adapted from Marty Stepp, University of Washington
Professor Evan Korth (adapted from Sun’s collections documentation)
Java Collection Framework. Interface Collection add(o) Add a new element clear() Remove all elements contains(o) Membership checking. IsEmpty() Whether.
24-Jun-15 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
Data Structures & Java Collections Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L15 (Chapter 22) Java Collections.
The Collections Framework A Brief Introduction. Collections A collection is a structured group of objects –An array is a kind of collection –A Vector.
Chapter 19 Java Data Structures
Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.
Java's Collection Framework
SEG4110 – Advanced Software Design and Reengineering TOPIC G Java Collections Framework.
Java Collections Framework A presentation by Eric Fabricant.
CS Collection and Input/Output Classes CS 3331 Fall 2009.
Sets and Maps Part of the Collections Framework. The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
CS-2851 Dr. Mark L. Hornick 1 Tree Maps and Tree Sets The JCF Binary Tree classes.
Java Programming: Advanced Topics 1 Collections and Wealth of Utilities Chapter 4.
Java Programming: Advanced Topics 1 Collections and Wealth of Utilities.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Collections F The limitations of arrays F Java Collection Framework hierarchy  Use the Iterator interface to traverse a collection  Set interface, HashSet,
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Collections in Java. Kinds of Collections Collection --a group of objects, called elements –Set-- An unordered collection with no duplicates SortedSet.
1 Java's Collection Framework By Rick Mercer with help from The Java Tutorial, The Collections Trail, by Joshua BlockThe Collections Trail.
(c) University of Washington14-1 CSC 143 Java Collections.
Jan 12, 2012 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
Big Java Chapter 16.
111 © 2002, Cisco Systems, Inc. All rights reserved.
CSS446 Spring 2014 Nan Wang.  Java Collection Framework ◦ Set ◦ Map 2.
Chapter 18 Java Collections Framework
1.0tCopyright © 1998 Purple Technology, Inc. 1 Java Collections Framework Authored by Alex Chaffee Copyright © 1998 Purple Technology, Inc. All rights.
Sets and Maps Chris Nevison. Set Interface Models collection with no repetitions subinterface of Collection –has all collection methods has a subinterface.
3-February-2003cse Collections © 2003 University of Washington1 Java Collections CSE 403, Winter 2003 Software Engineering
1 Collections Framework A collections framework is a unified architecture for representing and manipulating collections. All collections frameworks contain:
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
SETS AND MAPS Collections of Data. Advanced Data Structures Often referred to as the Java Collections Framework…. Set and map data types Hash tables Binary.
13 Collections Framework. 2 Contents What is Collection? Collections Framework Collections Hierarchy Collections Implementations Set List Map.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Thomas Kuehne.
Set and Map IS 313, Skeletons  Useful coding patterns  Should understand how and why they work how to use  possible quiz material.
Copyright (c) Systems and Computer Engineering, Carleton University * Object-Oriented Software Development Unit 13 The Collections Framework.
Maps Nick Mouriski.
Sets and Maps Part of the Collections Framework. 2 The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
1 Java's Collection Framework Map and Sets. 2 Collection Framework  A collections framework is a unified architecture for representing and manipulating.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Marcus Frean.
1 Copyright © 2011 Tata Consultancy Services Limited COLLECTIONS By TEAM 5 Rajendhiran Sivan Christi Yashwanth Bijay Smruthi Satyajit.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 21 Sets and Maps.
4-Mar-16 Introduction to Collections. Revision questions True false questions 0 for False 1 for True Please do not answer anything other than the above.
Collections Dwight Deugo Nesa Matic
CSE 143 Lecture 11: Sets and Maps reading:
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
Lecture 9:FXML and Useful Java Collections Michael Hsu CSULA.
CS 151: Object-Oriented Design December 3 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
©Karsten Lundqvist Example: Array and Arrays 1 import java.util.*; public class Example { private int intValues[] = { 1, 2, 3, 4, 5, 6 }; private double.
COMP2402 The Java Collections Framework II: Implementations and Algorithms Pat Morin.
Chapter 21 Sets and Maps Jung Soo (Sue) Lim Cal State LA.
Java Collections OOP tirgul No
Reference – Object Oriented Software Development Using Java - Jia
University of Central Florida COP 3330 Object Oriented Programming
JCF Hashmap & Hashset Winter 2005 CS-2851 Dr. Mark L. Hornick.
Road Map CS Concepts Data Structures Java Language Java Collections
Introduction to Collections
JAVA Collections Framework Set Interfaces & Implementations
TCSS 342, Winter 2006 Lecture Notes
Introduction to Collections
Part of the Collections Framework
Introduction to Collections
Introduction to Collections
Presentation transcript:

George Blank University Lecturer

CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 8

Application Frameworks Java has an extensive collection of application frameworks, collections of cooperating classes that can be used in developing applications. Chapter 8 emphasizes three such frameworks—collections, input/output and GUIs using AWT and Swing.

Expected knowledge Students should not only understand and be able to use the classes described in the text, but must also develop skill in using Java documentation to go beyond the material in the text. It is recommended that students become familiar with Another good site:

Chapter notes There is so much in this chapter that I hesitate to add more to the readings. I do recommend that students make certain that they understand the topics described in the chapter summary.

Abstract Collection Types A bag or multiset is an unordered collection of elements that may include duplicates. A bag, in Java the Collection interface, is the least restrictive and most general form of collection. A set is an unordered collection of elements without duplicates. A list is an ordered collection of elements. A map, dictionary or associative array is an unordered collection of key-value pairs.

Methods of Interface Collection add(element) addAll(collection) clear() contains(element) containsAll(collection) isEmpty() iterator() remove(element) removeAll(collection) retainAll(collection) size()

Methods of Interface List add(i,element) add(element) addAll(collection) addAll(i,collection) get(i) indexOf(element) lastIndexOf(element) containsAll(collection) listIterator() listIterator(i) remove(i) remove(element) removeAll(collection) set(i,element) subList(i,j)

Methods of Interface Map clear() containsKey(k) containsValue(v) entrySet() get(k) isEmpty() keySet() put(k,v) put(map) remove(k) removeAll(collection) size() values() k = key v = value

Types of Sets A HashSet stores elements in a hash table. A LinkedHashSet is an ordered hash table. A TreeSet stores elements in a balanced binary tree.

Concrete Collections Sets HashSet LinkedHashSet TreeSet 1 Lists Array List Linked List Vector Maps HashMap IndentityHashMap LinkedHashMap TreeMap 1 Hashtable 1 sorted

Ordering An order (technically a partial order) is a transitive binary relationship between two objects. Organized by some criteria, if a has a certain relationship with b and b has the same relationship with c, then a has that relationship with c. A sorted collection is one that orders its elements by a particular relationship.

Defining Orders on Objects A class can define a natural order among its instances by implementing the comparable interface. Arbitrary orders among different objects can be defined by comparators, or classes that by implement the comparator interface. SortedSet and SortedMap are sorted abstract collections that inherit the functions of sets and maps respectively.

Word Frequency example The Class WordFrequency2 on pages shows an example of using a sorted map sorted by their natural keys. It first orders the words in a piece of text and then counts the identical words to determine their frequency. Class WordFrequency4 on page 332 extends this to sort the result and display the words in frequency order.

Java Graphical User Interfaces Java has a GUI framework consisting of several categories of classes: GUI Components (widgets) have a characteristic appearance (look) and behavior (feel). Layout managers package components in windows. (see FlowLayout and BorderLayout ) Events and Event Listeners Grapics and Imaging classes

Abstract Windows Toolkit The basic Java GUI toolkit is the Abstract Windows Toolkit (AWT) The Swing package is an extension of AWT to build high quality GUIs. Review the hierarchy of awt at to see the wde variety of classes available to build GUI applications. The Java Class hierarchy is a good starting place to understand Java libraries:

Understanding Layouts It is important to practice using the layouts such a flow layouts in order to understand how to present information attractively to the end user. Problem 8.5 in the text is a good exercise for this purpose.

Bibliography Jia, Xiaoping, Object Oriented Software Development Using Java. Addison Wesley,