Java.util.Vector Brian Toone 10/3/07 Updated 10/10/07.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 5 The Collections API.
Advertisements

Introduction to Computation and Problem Solving Class 32: The Java® Collections Framework Prof. Steven R. Lerman and Dr. V. Judson Harward.
Transparency No. 1 Java Collection API : Built-in Data Structures for Java.
Collections Chapter Java Collection Frameworks The Java collection framework is a set of utility classes and interfaces. Designed for working with.
Collections Framework A very brief look at Java’s Collection Framework David Davenport May 2010.
Collections CS3250. Sources  Slides by Professor Chuck Allison  Core Java, by Cay S. Horstmann and Gary Cornell  The Java Tutorial 
Data Structures & Java Generics Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Java Collections Framework COMP53 Oct 24, Collections Framework A unified architecture for representing and manipulating collections Allows collections.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L16 (Chapter 22) Java Collections.
© 2006 Pearson Addison-Wesley. All rights reserved16-1 Methods in the List Interface (Part 1 of 16)
24-Jun-15 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
Introduction to Java Collections
1 Data Structures  We can now explore some advanced techniques for organizing and managing information  Chapter 12 of the book focuses on: dynamic structures.
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.
Chapter 8 Lists. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-2 Chapter Objectives Examine list processing and various ordering techniques.
12-Jul-15 Lists in Java Part of the Collections Framework.
Chapter 19 Java Data Structures
Java's Collection Framework
SEG4110 – Advanced Software Design and Reengineering TOPIC G Java Collections Framework.
Java Collections Framework A presentation by Eric Fabricant.
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.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
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.
Data structures and algorithms in the collection framework 1 Part 2.
111 © 2002, Cisco Systems, Inc. All rights reserved.
5-Aug-2002cse Arrays © 2002 University of Washington1 Arrays CSE 142, Summer 2002 Computer Programming 1
COLLECTIONS Byju Veedu s/Collection.html.
Some Other Collections: Bags, Sets, Queues and Maps COMP T2 Lecture 4 School of Engineering and Computer Science, Victoria University of Wellington.
Object Oriented Programming Ders 10: Data Structures Mustafa Emre İlal
Chapter 18 Java Collections Framework
Computer Science 209 Software Development Java Collections.
תוכנה 1 תרגול 8 – מבני נתונים גנריים. 2 Java Collections Framework Collection: a group of elements Interface Based Design: Java Collections Framework.
Data structures Abstract data types Java classes for Data structures and ADTs.
1/20/03A2-1 CS494 Interfaces and Collection in Java.
Collections –data structures and Algorithms L. Grewe.
Data structures and algorithms in the collection framework 1.
Arrays, ArrayLists, and Collections. Rationale Suppose we have a program to compute the average of three numbers. We could write a simple little method.
Collection 105 Yola. To store data in RAM Variables (name all the types with their length) Arrays (one, two or more) Collections and Maps.
Chapter 12: Collections by Lewis and Loftus (Updated by Dan Fleck) Coming up: Collections.
Practical Session 4 Java Collections. Outline Working with a Collection The Collection interface The Collection hierarchy Case Study: Undoable Stack The.
1 Interfaces in Java’s Collection Framework Rick Mercer.
Interface: (e.g. IDictionary) Specification class Appl{ ---- IDictionary dic; dic= new XXX(); application class: Dictionary SortedDictionary ----
Building Java Programs Bonus Slides Hashing. 2 Recall: ADTs (11.1) abstract data type (ADT): A specification of a collection of data and the operations.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
13 Collections Framework. 2 Contents What is Collection? Collections Framework Collections Hierarchy Collections Implementations Set List Map.
Maps Nick Mouriski.
1 Java's Collection Framework Map and Sets. 2 Collection Framework  A collections framework is a unified architecture for representing and manipulating.
CS Fall 2012, Lab 04 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Changes of Office Hours  Monday.
Collections Dwight Deugo Nesa Matic
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
Introduction to Java Collection. Java Collections What are they? –A number of pre-packaged implementations of common ‘container’ classes, such as LinkedLists,
Collections ABCD ABCD Head Node Tail Node array doubly linked list Traditional Arrays and linked list: Below is memory representation of traditional.
Java Collections OOP tirgul No
Sixth Lecture ArrayList Abstract Class and Interface
Chapter 19 Java Data Structures
Software Development Java Collections
University of Central Florida COP 3330 Object Oriented Programming
Chapter 12: Data Structures
Java Algorithms.
Java Collections Overview
Java Collections Framework
Môn: Lập trình Hướng đối tượng (Object Oriented Programming)
CSE 1020: The Collection Framework
1.4 ทบทวน JAVA OO Programming Concepts Declaring and Creating Objects
Introduction to Java Collection
Presentation transcript:

java.util.Vector Brian Toone 10/3/07 Updated 10/10/07

What is a Vector object? Think of it as a really convenient array Consider: What if we now want to add a 6 th element? What if we want to check to see if a particular element is contained in the array? What if we want to sort the elements?

The nice things about Vector Vector allows you to add elements “on-the-fly” Vector provides a method for automatically searching for a particular element in the array The java.util.Collections class provides a static method for sorting the elements in the array

Vector Examples Eclipse Solution to “We are the champions” Solution to “Village People”

java.util.Collections The Java Tutorial (Sun), Trail: Collections Library distributed with latest (> 1.4) versions of the JDK Consists of – Interfaces (Set, List, Queue, Map, SortedSet, SortedMap) – Implementations (HashSet, HashMap, ArrayList, LinkedList) – Algorithms (Sorting, Shuffling, Frequency, Composition) – Vector???

Example Algorithm: sort Algorithms provided as static methods in a class called Collections. Simple example: // Add as many elements as we want! Vector v = new Vector (); v.add(35); v.add(85); v.add(22); v.add(99); v.add(68); v.add(73); // Sort the array Collections.sort(v);

Example Interface: map Think of this as an associative array Associative arrays are found in some scripting languages such as PHP: $blogTitle = sanitize($_REQUEST['blogTitle']); $blogTags = sanitize($_REQUEST['blogTags']); $blogSummary = sanitize($_REQUEST['blogSummary']); $htmlArea = sanitize($_REQUEST['htmlarea']);

Let’s see an example in Java