Framework in Java 5. DAAD project Joint Course on OOP using Java

Size: px
Start display at page:

Download "Framework in Java 5. DAAD project Joint Course on OOP using Java"

Transcription

1 Topic XXX Collections Framework in Java 5 DAAD project Joint Course on OOP using Java Humboldt University Berlin, University of Novi Sad, Polytehnica University of Timisoara, University of Plovdiv, University of Belgrade Version: September 1, 2004 Collections Framework in Java 5 a) Collections Framework and Iterators b) Collection interface c) Sets d) Lists and Queues e) Maps f) Collections and Arrays classes DAAD project Joint Course on OOP using Java 2 1

2 Collections Collections: classes that store and manage groups of objects (aka containers) Collection framework: group of interfaces and classes in package java.util for working with: Sets Sequences (lists, queues) Maps Important property: automatic extension of size, to accomodate as many objects as required DAAD project Joint Course on OOP using Java 3 Iterators (1) Common operation: visiting/retrieval of all objects in a collection (iteration) Iterator: an object containing references to all objects in a collection Interface Iterator in package java.util: public interface Iterator <E> { boolean hasnext(); E next() void remove(); DAAD project Joint Course on OOP using Java 4 2

3 Iterators (2) Any class that uses iteration must implement the Iterator<> interface and provide a method that returns an iterator. Important: a new iterator is required for each iteration operation. The method for returning an iterator is specified in a separate interface, Iterable: public interface Iterable { Iterator<T> iterator(); DAAD project Joint Course on OOP using Java 5 Iterators (3) Lists can be traversed in both directions, and a new interface is defined for this special case: public interface ListIterator extends Iterator{ boolean hasprevious(); E previous(); int nextindex(); int previousindex(); void add(e o); void set(e o); add inserts immediately before the element to be returned by next call to next() set replaces the last object returned by next() or previous() DAAD project Joint Course on OOP using Java 6 3

4 Collections Framework in Java 5 a) Collections Framework and Iterators b) Collection interface c) Sets d) Lists and Queues e) Maps f) Collections and Arrays classes DAAD project Joint Course on OOP using Java 7 Collection interface (1) There are 5 interfaces for sequences and 2 for maps in the java.util package DAAD project Joint Course on OOP using Java 8 4

5 Collection interface(2) public interface Collection<E>extends Iterable<E> { boolean add(e o); boolean addall(collection<? extends E> c); void clear(); boolean contains(object o); boolean containsall(collection<?> c); boolean equals(object o); int hashcode(); boolean isempty(); Iterator<E>iterator(); boolean remove(object o); boolean removeall(collection<?> c); boolean retainsall(collection<?> c); int size(); Object[ ] toarray(); <T> t[ ] toarray(t[ ] a); DAAD project Joint Course on OOP using Java 9 Collection interface(3) The distructive methods (add, addall, clear, remove, removeall, retainall) are optional, in the sense that they should not be implemented in all classes that implement Collection Calls to non-implemented methods will generate UnsupportedOperationException Implementations of equals and hashcode must satisfy: c1.equals(c2) =>c1.hashcode()==c2.hashcode() The toarray methods are a bridge between collections and arrays, the last method also controlls the type of the returned array There is an abstact class that implements Collection, with size() and iterator() as abstract methods: AbstractCollection DAAD project Joint Course on OOP using Java 10 5

6 Collections Framework in Java 5 a) Collections Framework and Iterators b) Collection interface c) Sets d) Lists and Queues e) Maps f) Collections and Arrays classes DAAD project Joint Course on OOP using Java 11 Sets: Interfaces(1) The Set interface has no new methods, but imposes restrictions on some of the Collection methods: For equals: s1.equals(s2) returns true iff s2 is a set, and s1 and s2 have thesamesize, andeachmemberof s2 is contained in s1 For hashcode: the hash code of a set is the sum of the hash codes of all members For add: the element is not added if already present in the set (sets do not allow duplicates) A Set cannot contain itself as an element DAAD project Joint Course on OOP using Java 12 6

7 Sets: Interfaces(2) A Set can be sorted, such that an iterator traverses it in the natural order (Comparable)of the members, or the order given by a Comparator Comparable interface (part of java.lang): public interface Comparable<T>{ int compareto( T o); Comparable is implemented in many standard classes, including wrapper classes, String, Calendar, Date, Time. Comparator interface (part of java.util ): public interface Comparator<T> { int compare (T o1, T o2); boolean equals(object obj); The order imposed by Comparable and Comparator must be compatible with equality, i.e. e1.compareto(e2)==0 has the same boolean value as e1.equals((object)e2). DAAD project Joint Course on OOP using Java 13 Sets: interfaces(3) Implementations of compare() must ensure transitivity: ((compare(x,y)>0) && (compare(y,z)>0)) =>compare(x,z)>0 equals is redefined to emphasize that the parameter must also be a Comparator with the same order as the current object Sorted sets must implement the interface: public interface SortedSet<E>extends Set<E> { Comparator<? super E>comparator(); E first(); E last(); SortedSet<E> headset(e toelement); SortedSet<E> subset(e fromelement, E toelement); SortedSet<E> tailset (E fromelement); The last 3 methods return views of the original set, thus any change in the original set is immediately reflected in the subset DAAD project Joint Course on OOP using Java 14 7

8 Sets: abstract class java.util contains an abstract class which implements Set: public abstract class AbstractSet<E> extends AbstractCollection<E>implements Set<E> This class does not override the AbstractCollection methods, except for removeall,and it adds implementations for equals and hashcode of class Object, according to the requirements of Set. AbstractSet has a protected constructor, to be used by classes derived from it DAAD project Joint Course on OOP using Java 15 Sets: «concrete» classes (1) java.util provides the following classes for sets, lists and queues: DAAD project Joint Course on OOP using Java 16 8

9 Sets: <<concrete concrete>> classes (2) TreeSet, HashSet and LinkedHashSet are backed by Maps, and will be presented later EnumSet is, in fact, an abstract class: public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E> implements Cloneable, Serializable All elements of an EnumSet must come from a single Enum type Very efficient internal representation, as a bit vector All the basic operations execute in constant time Type-safe alternative to traditional int-based «bit flags» null elements not permitted Non-synchronized, like most concrete classes of the collections framework DAAD project Joint Course on OOP using Java 17 Collections Framework in Java 5 a) Collections Framework and Iterators b) Collection interface c) Sets d) Lists and Queues e) Maps f) Collections and Arrays classes DAAD project Joint Course on OOP using Java 18 9

10 The interface for lists (1) Unlike Sets, lists allow duplicate elements There is an exact control on the position of elements There are restrictions on contracts of methods inherited from Collection, and new methods The List interface (only new methods shown): public interface List<E> extends Collection<E> { void add (int index, E element); boolean addall(int index, Collection<? extends E> c); E get (int index); int indexof (Object o); int lastindexof (Object o); ListIterator<E>listIterator(); ListIterator<E> listiterator(int index); E remove (int index); E set (int index, E element); List<E> sublist(int fromindex, int toindex); DAAD project Joint Course on OOP using Java 19 The interface for lists (2) Inherited addall adds at the end of current list, in the order given by the iterator of the specified Collection New addall adds in the specified position, the indexes of elements after the given index willchange Inherited remove: deletes the first occurrence of the specified element New remove deletes the element in the specified position sublist returns a view of the original List equals and hashcode are redefined: two lists are equal if they contain the same elements in the same order; the hash code of a list is calculated as follows: hashcode = 1; Iterator i = list.iterator(); while (i.hasnext()) { Object obj = i.next(); hashcode = 31*hashCode + (obj==null? 0 : obj.hashcode()); DAAD project Joint Course on OOP using Java 20 10

11 Abstract classes for Lists(1) AbstractList provides an implementation of List backed by a random access data store (e.g. an array): public abstract class AbstractList<E> extends AbstractCollection<E> implements List<E> All methods, except get and size, are implemented and there is also a protected constructor Derived classes must override set and add in order have a modifiable and variable-size list Iterator methods do not have to be overriden DAAD project Joint Course on OOP using Java 21 Abstract classes for lists (2) AbstractSequentialList implements List backed by a sequential acces data store: public abstract class AbstractSequentialList<E> extends AbstractList<E> Now the iterator method is fundamental, and the «random access» methods ( get, set, add, remove) are implemented on top of it The listiterator method is abstract and must be implemented in derived classes, together with the methods of the ListIterator interface For modifiable lists, set, remove and add must also be implemented DAAD project Joint Course on OOP using Java 22 11

12 Class Vector (1) Was introduced already in JDK 1.0, before defining collections framework, and retrofitted in Java 2 to implement List: public class Vector<E>extends AbstractList implements List<E>, RandomAccess, Cloneable, Serializable Represents, in fact, an array of objects whose size can grow and shrink as required Tries to optimize memory management with a field, capacityincrement; if not specified, the capacity is doubled when incrementation is required The implementation is synchronized (thread-safe) Has new methods: capacity, trimtosize, ensurecapacity, setsize DAAD project Joint Course on OOP using Java 23 Class Vector (2) Example: a class modelling a company can use a Vector to store data about employees: class Company { private Vector<Empl> v = new Vector<Empl>(); public void hire(){ Empl e = new Empl(); int i=0; if(v.size()==0) v.add(e); else { while (i <v.size() && e.getname().compareto(v.elementat(i).getnume())>0) i++; v.add(i,e); DAAD project Joint Course on OOP using Java 24 12

13 Classes Stack and ArrayList Class Stack: Declared as follows: public class Stack<E> extends Vector<E> Adds 5 new methods: push, pop, peek (returns the top element, without removing it from stack), empty, and search (if an Object is present on stack) Implementation is synchronized ( old class) Class ArrayList: Similar to Vector, but not synchronized Declared as follows: public class ArrayList<E>extends AbstractList<E>implements List<E>, RandomAcces, Cloneable, Serializable Does not have addelement, capacity, removeelementat of Vector, has: trimtosize, ensurecapacity DAAD project Joint Course on OOP using Java 25 Class LinkedList(1) Implements double-linked lists, with sequential access Declared as: public class LinkedList <E>extends AbstractSequentialList<E>implements List<E>, Queue<E>, Cloneable, Serializable Some operations require more time than on Vector or ArrayList New methods for operations at the head or tail of list: getfirst, getlast (no change in list) removefirst, removelast addfirst, addlast Recommended when operations in the middle of the list are frequent (take O(1) time) Needs iterators DAAD project Joint Course on OOP using Java 26 13

14 Class LinkedList (2) Previous example (data about a company s employees) implemented with a linked list: class Company { private LinkedList<Empl> el = new LinkedList<Empl>(); public void hire(){ Empl e = new Empl(); int i = 0; Iterator<Empl>iter = el.listiterator(); if (el.size()==0) el.add(e); else{ while(iter.hasnext() && e.getname().compareto(iter.next().getname())>0) i++; el.add(i, e); DAAD project Joint Course on OOP using Java 27 Queues Queue interface: public interface Queue<E> extends Collection<E> E element();//returns first elem.(no changeexception) boolean offer(e o); E peek();//returns first elem. (no change-null) E poll();//returns and removes (null when empty) E remove();//returns and removes (exception) Class AbstractQueue: public abstract class AbstractQueue<E> extends AbstractCollection<E> implements Queue<e> Methods not implemented: offer, poll, peek, size, iterator Class PriorityQueue: a queue with natural order of elements: public class PriorityQueue<E> extends AbstractQueue<E> implements Serializable DAAD project Joint Course on OOP using Java 28 14

15 Collections Framework in Java 5 a) Collections Framework and Iterators b) Collection interface c) Sets d) Lists and Queues e) Maps f) Collections and Arrays classes DAAD project Joint Course on OOP using Java 29 Map interface A Map cannot have duplicate keys A Mapcontainsatmostonevalue associated with a key Map interface: public interface Map<K, V> { public static interface Map.Entry<K, V>{ boolean equals (Object o); K getkey(); V getvalue(); int hashcode(); V setvalue(v value); void clear(); boolean containskey(object key); boolean containsvalue(object value); Set<Map.Entry<K,V>>entrySet(); boolean equals(object o); V get(object key); int hashcode(); boolean isempty(); Set<K> keyset(); V put(k key, V value): void putall(map<?extends K,? Extends V> t); V remove(object key); int size(); Collection<V> values(); Three Collection views: keys, values, entries All views are backed by the map put: if the map already contains the key, the old associated value is replaced with the new Optional methods: put, putall, clear, remove DAAD project Joint Course on OOP using Java 30 15

16 Interface SortedMap Guarantees ascending order of keys (natural order, or given by Comparator) Definition: public SortedMap<K,V>extends Map<K,V> { Comparator<? Super K>comparator(); K firstkey(); SortedMap<K, V> headmap(k tokey); K lastkey(); SortedMap<K,V> submap(k fromkey, K tokey); SortedMap<K,V> tailmap (K fromkey); All partial views are backed by the original map headmap: entries with keys strictly less than tokey submap: inludes fromkey, excludes tokey tailmap: includes fromkey DAAD project Joint Course on OOP using Java 31 Classes for Maps General view of the classes provided in the colections framework for Maps: DAAD project Joint Course on OOP using Java 32 16

17 Class HashMap (1) Auxiliary classes: Dictionary and Hashtable Dictionary: present since JDK1.0, considered obsolete, used only by Hashtable Hashtable declaration: public class Hashtable<K,V> extends Dictionary<K,V> implements Map<K,V>, Cloneable, Serializable Two important parameters: initial capacity and load factor (default values: 11 and 0.75) In case of bucket collisions, entries are chained Capacity is automatically increased when load factor is exceeded; involves rehashing Abstract class: AbstractMap: public abstract class AbstractMap<K, V> extends Object implements Map<K,V> For unmodifiable maps: implement entryset For modfiable maps: override put, implement remove of iterator DAAD project Joint Course on OOP using Java 33 Class HashMap (2) Declaration of HashMap: public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable Hash table based implementation of Map Provides all optional Map operations, allows null keys Roughly equivalent to Hashtable, but unsynchronized and permits nulls Makes no guarantees as to the order of the map Provides constant time performance for basic operations: get, put The iterators, like in most other cases are fail-fast:if the map is structurally modified at any time after the iterator is created, in any way except through the iterator's own remove or add methods, the iterator will throw a ConcurrentModificationException. Four constructors: HashMap(), HashMap(int initialcapacity), HashMap(int initialcapacity, float loadfactor), HashMap(Map<? extends K,? extends V> m) DAAD project Joint Course on OOP using Java 34 17

18 Class HashMap (3) Example of use: a phone book, with person names as keys, and file save/restore operations for the phone book Persons are defined in a separate class, provided with an appropriate hashcode method: public int hashcode(){ return 13*name.hashCode() + 19*surname.hashCode(); A separate class defines an entry of phone book: person and phone number The class PhoneBook: class PhoneBook implements Serializable { private HashMap<Pers, PBEntry> pb = new HashMap<Pers, PBEntry>(); public getentry(pers key){ return pb.get(key); public getphone(pers key) { return getentry(key).getnumber(); DAAD project Joint Course on OOP using Java 35 Collections Framework in Java 5 a) Collections Framework and Iterators b) Collection interface c) Sets d) Lists and Queues e) Maps f) Collections and Arrays classes DAAD project Joint Course on OOP using Java 36 18

19 Collections class Contains only static methods that operate on or return collections: Polymorphic algorithms operating on collections Wrappers returning a new collection backed by a specified collection Odds and ends Examples: static int frequency(collection<?> c, Object o) static <T>void fill(list<? super T>list, T obj) static <T>T max(collection<? extends T>coll, Comparator<? super T> comp) static void reverse(list<?> list) static <K,V>Map<K,V>singletonMap(K key, V value) static <T>void sort(list<t>list, Comparator<?super T>c) static <T> int binarysearch (List<? extends Comparable<? super T>> list, T key) static <T>Collection<T> synchronizedcollection (Collection<T> c) backed by the specified collection. To guarantee serial access: all access to the backed collection accomplished through the returned collection Collection c = Collections.synchronizedColle ction(mycollection); synchronized(c) { Iterator i = c.iterator(); while (i.hasnext()) foo(i.next()); DAAD project Joint Course on OOP using Java 37 Arrays class Contains static methods for: Manipulating arrays (sorting, searching) Factory for viewing arrays as lists Examples: public static <T> void sort (T[ ] a, Comparator<? super T> c) public static <T> int binarysearch(t[ ] a, T key, Comparator<? super T> c) public static boolean deepequals(object [ ] a, Object[ ] a2)- works on nested arrays of arbitrary level public static void fill(object[ ]a, int fromindex, int toindex, Object val) public static <T> List<T> aslist(t a)- returns a fixed-size list backed by the array DAAD project Joint Course on OOP using Java 38 19

Class 32: The Java Collections Framework

Class 32: The Java Collections Framework Introduction to Computation and Problem Solving Class 32: The Java Collections Framework Prof. Steven R. Lerman and Dr. V. Judson Harward Goals To introduce you to the data structure classes that come

More information

Type Parameters: E - the type of elements returned by this iterator Methods Modifier and Type Method and Description

Type Parameters: E - the type of elements returned by this iterator Methods Modifier and Type Method and Description java.lang Interface Iterable Type Parameters: T - the type of elements returned by the iterator Iterator iterator() Returns an iterator over a set of elements of type T. java.util Interface Iterator

More information

Arrays organize each data element as sequential memory cells each accessed by an index. data data data data data data data data

Arrays organize each data element as sequential memory cells each accessed by an index. data data data data data data data data 1 JAVA PROGRAMMERS GUIDE LESSON 1 File: JGuiGuideL1.doc Date Started: July 10, 2000 Last Update: Jan 2, 2002 Status: proof DICTIONARIES, MAPS AND COLLECTIONS We have classes for Sets, Lists and Maps and

More information

CONTAİNERS COLLECTİONS

CONTAİNERS COLLECTİONS CONTAİNERS Some programs create too many objects and deal with them. In such a program, it is not feasible to declare a separate variable to hold reference to each of these objects. The proper way of keeping

More information

Generics Collection Framework

Generics Collection Framework Generics Collection Framework Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 Generics

More information

CSC 1214: Object-Oriented Programming

CSC 1214: Object-Oriented Programming CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:

More information

Collections class Comparable and Comparator. Slides by Mark Hancock (adapted from notes by Craig Schock)

Collections class Comparable and Comparator. Slides by Mark Hancock (adapted from notes by Craig Schock) Lecture 15 Summary Collections Framework Iterable, Collections List, Set Map Collections class Comparable and Comparator 1 By the end of this lecture, you will be able to use different types of Collections

More information

Lecture 15 Summary. Collections Framework. Collections class Comparable and Comparator. Iterable, Collections List, Set Map

Lecture 15 Summary. Collections Framework. Collections class Comparable and Comparator. Iterable, Collections List, Set Map Lecture 15 Summary Collections Framework Iterable, Collections List, Set Map Collections class Comparable and Comparator 1 By the end of this lecture, you will be able to use different types of Collections

More information

Java Collections. Readings and References. Collections Framework. Java 2 Collections. References. CSE 403, Winter 2003 Software Engineering

Java Collections. Readings and References. Collections Framework. Java 2 Collections. References. CSE 403, Winter 2003 Software Engineering Readings and References Java Collections References» "Collections", Java tutorial» http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Winter 2003 Software Engineering http://www.cs.washington.edu/education/courses/403/03wi/

More information

Collections (Collection Framework) Sang Shin Java Technology Architect Sun Microsystems, Inc.

Collections (Collection Framework) Sang Shin Java Technology Architect Sun Microsystems, Inc. Collections (Collection Framework) Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com www.javapassion.com 2 Disclaimer & Acknowledgments Even though Sang Shin is a full-time employee

More information

Topic #9: Collections. Readings and References. Collections. Collection Interface. Java Collections CSE142 A-1

Topic #9: Collections. Readings and References. Collections. Collection Interface. Java Collections CSE142 A-1 Topic #9: Collections CSE 413, Autumn 2004 Programming Languages http://www.cs.washington.edu/education/courses/413/04au/ If S is a subtype of T, what is S permitted to do with the methods of T? Typing

More information

Collections Framework: Part 2

Collections Framework: Part 2 Collections Framework: Part 2 Computer Science and Engineering College of Engineering The Ohio State University Lecture 18 Collection Implementations Java SDK provides several implementations of Collection

More information

Vector (Java 2 Platform SE 5.0) Overview Package Class Use Tree Deprecated Index Help

Vector (Java 2 Platform SE 5.0) Overview Package Class Use Tree Deprecated Index Help Overview Package Class Use Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes SUMMARY: NESTED FIELD CONSTR METHOD DETAIL: FIELD CONSTR METHOD Página 1 de 30 Java TM 2 Platform

More information

Lecture 6 Collections

Lecture 6 Collections Lecture 6 Collections Concept A collection is a data structure actually, an object to hold other objects, which let you store and organize objects in useful ways for efficient access Check out the java.util

More information

Collections and Maps

Collections and Maps Collections and Maps Comparing Objects The majority of the non-final methods of the Object class are meant to be overridden. They provide general contracts for objects, which the classes overriding the

More information

A simple map: Hashtable

A simple map: Hashtable Using Maps A simple map: Hashtable To create a Hashtable, use: import java.util.*; Hashtable table = new Hashtable(); To put things into a Hashtable, use: table.put(key, value); To retrieve a value from

More information

Sets and Maps. Part of the Collections Framework

Sets and Maps. Part of the Collections Framework 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 int size( ); boolean isempty( ); boolean contains(object

More information

Generics and collections

Generics and collections Generics From JDK 1.5.0 They are similar to C++ templates They allow to eliminate runtime exceptions related to improper casting (ClassCastException) Traditional approach public class Box { private Object

More information

Lecture 15 Summary 3/11/2009. By the end of this lecture, you will be able to use different types of Collections and Maps in your Java code.

Lecture 15 Summary 3/11/2009. By the end of this lecture, you will be able to use different types of Collections and Maps in your Java code. Lecture 15 Summary Collections Framework Iterable, Collections, Set Map Collections class Comparable and Comparator By the end of this lecture, you will be able to use different types of Collections and

More information

DM550 Introduction to Programming part 2. Jan Baumbach.

DM550 Introduction to Programming part 2. Jan Baumbach. DM550 Introduction to Programming part 2 Jan Baumbach jan.baumbach@imada.sdu.dk http://www.baumbachlab.net Sorting Tree Balancing A sorted tree is balanced iff for each node holds: Math.abs(size(node.left)

More information

Introduction to Collections

Introduction to Collections Module 3 COLLECTIONS Introduction to Collections > A collection sometimes called a container is simply an object that groups multiple elements into a single unit. > Collections are used to store, retrieve,

More information

Collections IS311. The Collections Framework. Type Trees for Collections. Java Collections Framework (ต อ)

Collections IS311. The Collections Framework. Type Trees for Collections. Java Collections Framework (ต อ) IS311 Java Collections Framework (ต อ) Collections Collections are holders that let you store and organize objects in useful ways for efficient access. In the package java.util, there are interfaces and

More information

IS311. Java Collections Framework (ต อ)

IS311. Java Collections Framework (ต อ) IS311 Java Collections Framework (ต อ) 1 Collections Collections are holders that let you store and organize objects in useful ways for efficient access. In the package java.util, there are interfaces

More information

엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University

엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University 엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University C O P Y R I G H T S 2 0 1 5 E O M, H Y E O N S A N G A L L R I G H T S R E S E R V E D - Containers - About Containers

More information

JAVA. java.lang.stringbuffer java.lang.stringbuilder

JAVA. java.lang.stringbuffer java.lang.stringbuilder JAVA java.lang.stringbuffer java.lang.stringbuilder 1 Overview mutable string instances of String are immutable do not extend String String, StringBuffer, StringBuilder are final StringBuffer safe for

More information

Collections Questions

Collections Questions Collections Questions https://www.journaldev.com/1330/java-collections-interview-questions-and-answers https://www.baeldung.com/java-collections-interview-questions https://www.javatpoint.com/java-collections-interview-questions

More information

Generic classes & the Java Collections Framework. *Really* Reusable Code

Generic classes & the Java Collections Framework. *Really* Reusable Code Generic classes & the Java Collections Framework *Really* Reusable Code First, a bit of history Since Java version 5.0, Java has borrowed a page from C++ and offers a template mechanism, allowing programmers

More information

Collections (Java) Collections Framework

Collections (Java) Collections Framework Collections (Java) https://docs.oracle.com/javase/tutorial/collections/index.html Collection an object that groups multiple elements into a single unit. o store o retrieve o manipulate o communicate o

More information

PIC 20A Collections and Data Structures

PIC 20A Collections and Data Structures PIC 20A Collections and Data Structures Ernest Ryu UCLA Mathematics Last edited: March 14, 2018 Introductory example How do you write a phone book program? Some programmers may yell hash table! and write

More information

What is the Java Collections Framework?

What is the Java Collections Framework? 1 of 13 What is the Java Collections Framework? To begin with, what is a collection?. I have a collection of comic books. In that collection, I have Tarzan comics, Phantom comics, Superman comics and several

More information

DM550 Introduction to Programming part 2. Jan Baumbach.

DM550 Introduction to Programming part 2. Jan Baumbach. DM550 Introduction to Programming part 2 Jan Baumbach jan.baumbach@imada.sdu.dk http://www.baumbachlab.net MULTIVARIATE TREES 2 Multivariate Trees general class of trees nodes can have any number of children

More information

Java Collections. Readings and References. Collections Framework. Java 2 Collections. CSE 403, Spring 2004 Software Engineering

Java Collections. Readings and References. Collections Framework. Java 2 Collections. CSE 403, Spring 2004 Software Engineering Readings and References Java Collections "Collections", Java tutorial http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Spring 2004 Software Engineering http://www.cs.washington.edu/education/courses/403/04sp/

More information

Java Collections Framework: Interfaces

Java Collections Framework: Interfaces Java Collections Framework: Interfaces Introduction to the Java Collections Framework (JCF) The Comparator Interface Revisited The Collection Interface The List Interface The Iterator Interface The ListIterator

More information

Java Collections Framework reloaded

Java Collections Framework reloaded Java Collections Framework reloaded October 1, 2004 Java Collections - 2004-10-01 p. 1/23 Outline Interfaces Implementations Ordering Java 1.5 Java Collections - 2004-10-01 p. 2/23 Components Interfaces:

More information

27/04/2012. Objectives. Collection. Collections Framework. "Collection" Interface. Collection algorithm. Legacy collection

27/04/2012. Objectives. Collection. Collections Framework. Collection Interface. Collection algorithm. Legacy collection Objectives Collection Collections Framework Concrete collections Collection algorithm By Võ Văn Hải Faculty of Information Technologies Summer 2012 Legacy collection 1 2 2/27 Collections Framework "Collection"

More information

JAVA. java.lang.stringbuffer java.lang.stringbuilder

JAVA. java.lang.stringbuffer java.lang.stringbuilder JAVA java.lang.stringbuffer java.lang.stringbuilder 1 Overview mutable string instances of String are immutable do not extend String String, StringBuffer, StringBuilder are final StringBuffer safe for

More information

Java Collections Framework. 24 April 2013 OSU CSE 1

Java Collections Framework. 24 April 2013 OSU CSE 1 Java Collections Framework 24 April 2013 OSU CSE 1 Overview The Java Collections Framework (JCF) is a group of interfaces and classes similar to the OSU CSE components The similarities will become clearly

More information

The Java Collections Framework. Chapters 7.5

The Java Collections Framework. Chapters 7.5 The Java s Framework Chapters 7.5 Outline Introduction to the Java s Framework Iterators Interfaces, Classes and Classes of the Java s Framework Outline Introduction to the Java s Framework Iterators Interfaces,

More information

Recap. List Types. List Functionality. ListIterator. Adapter Design Pattern. Department of Computer Science 1

Recap. List Types. List Functionality. ListIterator. Adapter Design Pattern. Department of Computer Science 1 COMP209 Object Oriented Programming Container Classes 3 Mark Hall List Functionality Types List Iterator Adapter design pattern Adapting a LinkedList to a Stack/Queue Map Functionality Hashing Performance

More information

SUMMARY INTRODUCTION COLLECTIONS FRAMEWORK. Introduction Collections and iterators Linked list Array list Hash set Tree set Maps Collections framework

SUMMARY INTRODUCTION COLLECTIONS FRAMEWORK. Introduction Collections and iterators Linked list Array list Hash set Tree set Maps Collections framework SUMMARY COLLECTIONS FRAMEWORK PROGRAMMAZIONE CONCORRENTE E DISTR. Università degli Studi di Padova Dipartimento di Matematica Corso di Laurea in Informatica, A.A. 2015 2016 Introduction Collections and

More information

COURSE 4 PROGRAMMING III OOP. JAVA LANGUAGE

COURSE 4 PROGRAMMING III OOP. JAVA LANGUAGE COURSE 4 PROGRAMMING III OOP. JAVA LANGUAGE PREVIOUS COURSE CONTENT Inheritance Abstract classes Interfaces instanceof operator Nested classes Enumerations COUSE CONTENT Collections List Map Set Aggregate

More information

Overview$of$Collection$and$Map$Types

Overview$of$Collection$and$Map$Types Java$API$Extract:$Collection,$Map,$ Functional$Interfaces$and$Streams (JDK$1.2$or$laterD$presentation$is$not$complete!)! Overview of Collection$and Map Types! Iterable,$Iterator and ListIterator! Collection!

More information

Collection Framework Collection, Set, Queue, List, Map 3

Collection Framework Collection, Set, Queue, List, Map 3 Collection Framework Collection, Set, Queue, List, Map 3 1 1. Beginner - What is Collection? What is a Collections Framework? What are the benefits of Java Collections Framework? 3 2. Beginner - What is

More information

Lecture 4. The Java Collections Framework

Lecture 4. The Java Collections Framework Lecture 4. The Java s Framework - 1 - Outline Introduction to the Java s Framework Iterators Interfaces, Classes and Classes of the Java s Framework - 2 - Learning Outcomes From this lecture you should

More information

Java Collection Framework

Java Collection Framework Java Collection Framework Readings Purpose To provide a working knowledge of the Java Collections framework and iterators. Learning Objectives Understand the structure of the Java Collections framework

More information

An Interface with Generics

An Interface with Generics Generics CSC207 Software Design Generics An Interface with Generics Generics class foo introduces a class with a type parameter T. introduces a type parameter that is required to be

More information

CS Ananda Gunawardena

CS Ananda Gunawardena CS 15-121 Ananda Gunawardena A collection (sometimes called a container) is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve and manipulate data,

More information

17. Java Collections. Organizing Data. Generic List in Java: java.util.list. Type Parameters ( Parameteric Polymorphism ) Data Structures that we know

17. Java Collections. Organizing Data. Generic List in Java: java.util.list. Type Parameters ( Parameteric Polymorphism ) Data Structures that we know Organizing Data Data Structures that we know 17 Java Collections Generic Types, Iterators, Java Collections, Iterators Today: Arrays Fixed-size sequences Strings Sequences of characters Linked Lists (up

More information

COMP6700/2140 Abstract Data Types: Queue, Set, Map

COMP6700/2140 Abstract Data Types: Queue, Set, Map COMP6700/2140 Abstract Data Types: Queue, Set, Map Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU 19 April 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140

More information

CMSC 202H. Containers and Iterators

CMSC 202H. Containers and Iterators CMSC 202H Containers and Iterators Container Definition A container is a data structure whose purpose is to hold objects. Most languages support several ways to hold objects Arrays are compiler-supported

More information

Principles of Software Construction: Objects, Design and Concurrency. More design patterns and Java Collections. toad

Principles of Software Construction: Objects, Design and Concurrency. More design patterns and Java Collections. toad Principles of Software Construction: Objects, Design and Concurrency 15-214 toad More design patterns and Java Collections Spring 2013 Christian Kästner Charlie Garrod School of Computer Science 2012-13

More information

9/16/2010 CS Ananda Gunawardena

9/16/2010 CS Ananda Gunawardena CS 15-121 Ananda Gunawardena A collection (sometimes called a container) is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve and manipulate data,

More information

The Collections API. Lecture Objectives. The Collections API. Mark Allen Weiss

The Collections API. Lecture Objectives. The Collections API. Mark Allen Weiss The Collections API Mark Allen Weiss Lecture Objectives To learn how to use the Collections package in Java 1.2. To illustrate features of Java that help (and hurt) the design of the Collections API. Tuesday,

More information

Java collections framework

Java collections framework Java collections framework Commonly reusable collection data structures Java Collections Framework (JCF) Collection an object that represents a group of objects Collection Framework A unified architecture

More information

Abstract data types (again) Announcements. Example ADT an integer bag (next) The Java Collections Framework

Abstract data types (again) Announcements. Example ADT an integer bag (next) The Java Collections Framework Announcements Abstract data types (again) PS 5 ready Tutoring schedule updated with more hours Today s topic: The Java Collections Framework Reading: Section 7.5 An ADT is a model of a collection of data

More information

Family Name:... Other Names:... ID Number:... Signature... Model Solutions. COMP 103: Test 1. 9th August, 2013

Family Name:... Other Names:... ID Number:... Signature... Model Solutions. COMP 103: Test 1. 9th August, 2013 Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Model Solutions COMP 103: Test

More information

EXAMINATIONS 2016 TRIMESTER 2

EXAMINATIONS 2016 TRIMESTER 2 T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2016 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

More information

11-1. Collections. CSE 143 Java. Java 2 Collection Interfaces. Goals for Next Several Lectures

11-1. Collections. CSE 143 Java. Java 2 Collection Interfaces. Goals for Next Several Lectures Collections CSE 143 Java Collections Most programs need to store and access collections of data Collections are worth studying because... They are widely useful in programming They provide examples of

More information

Java collections framework

Java collections framework Java collections framework Commonly reusable collection data structures Abstract Data Type ADTs store data and allow various operations on the data to access and change it ADTs are mathematical models

More information

Topic 10: The Java Collections Framework (and Iterators)

Topic 10: The Java Collections Framework (and Iterators) Topic 10: The Java Collections Framework (and Iterators) A set of interfaces and classes to help manage collections of data. Why study the Collections Framework? very useful in many different kinds of

More information

Overview of Java ArrayList, HashTable, HashMap, Hashet,LinkedList

Overview of Java ArrayList, HashTable, HashMap, Hashet,LinkedList Overview of Java ArrayList, HashTable, HashMap, Hashet,LinkedList This article discusses the main classes of Java Collection API. The following figure demonstrates the Java Collection framework. Figure

More information

CMSC 202. Containers

CMSC 202. Containers CMSC 202 Containers Container Definition A container is a data structure whose purpose is to hold objects. Most languages support several ways to hold objects. Arrays are compiler-supported containers.

More information

EXAMINATIONS 2015 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

EXAMINATIONS 2015 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS T E W H A R E W Ā N A N G A O T E Student ID:....................... Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2015 TRIMESTER 2 COMP103 INTRODUCTION

More information

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 7. (A subset of) the Collections Interface. The Java Collections Interfaces

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 7. (A subset of) the Collections Interface. The Java Collections Interfaces Taking Stock IE170: Algorithms in Systems Engineering: Lecture 7 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University January 29, 2007 Last Time Practice Some Sorting Algs

More information

[Ref: Core Java Chp 13, Intro to Java Programming [Liang] Chp 22, Absolute Java Chp 16, docs.oracle.com/javase/tutorial/collections/toc.

[Ref: Core Java Chp 13, Intro to Java Programming [Liang] Chp 22, Absolute Java Chp 16, docs.oracle.com/javase/tutorial/collections/toc. Contents Topic 08 - Collections I. Introduction - Java Collection Hierarchy II. Choosing/using collections III. Collection and Iterator IV. Methods of Collection V. Concrete classes VI. Implementation

More information

Pieter van den Hombergh Thijs Dorssers Stefan Sobek. June 8, 2017

Pieter van den Hombergh Thijs Dorssers Stefan Sobek. June 8, 2017 Pieter van den Hombergh Thijs Dorssers Stefan Sobek Fontys Hogeschool voor Techniek en Logistiek June 8, 2017 /FHTenL June 8, 2017 1/19 Collection Zoo The basic collections, well known in programming s

More information

Lists and Iterators. CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology

Lists and Iterators. CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology Lists and Iterators CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology Announcements Should be making progress on VectorGraphics. Should have turned in CRC cards,

More information

Top level classes under java.util

Top level classes under java.util collections The java.util package also contains one of Java s most powerful subsystems: the Collections Framework. The Collections Framework is a sophisticated hierarchy of interfaces and classes that

More information

EXAMINATIONS 2017 TRIMESTER 2

EXAMINATIONS 2017 TRIMESTER 2 T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2017 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

More information

Abstract Data Types Spring 2018 Exam Prep 5: February 12, 2018

Abstract Data Types Spring 2018 Exam Prep 5: February 12, 2018 CS 61B Abstract Data Types Spring 2018 Exam Prep 5: February 12, 2018 1 Assorted ADTs A list is an ordered collection, or sequence. 1 interface List { 2 boolean add(e element); 3 void add(int index,

More information

Abstract Data Types (ADTs) Example ADTs. Using an Abstract Data Type. Class #08: Linear Data Structures

Abstract Data Types (ADTs) Example ADTs. Using an Abstract Data Type. Class #08: Linear Data Structures Abstract Data Types (ADTs) Class #08: Linear Data Structures Software Design III (CS 340): M. Allen, 08 Feb. 16 An ADT defines a kind of computational entity: A set of objects, with possible values A set

More information

Generics. IRS W-9 Form

Generics. IRS W-9 Form Generics IRS W-9 Form Generics Generic class and methods. BNF notation Syntax Non-parametrized class: < class declaration > ::= "class" < identifier > ["extends" < type >] ["implements" < type list >]

More information

Pieter van den Hombergh Richard van den Ham. February 8, 2018

Pieter van den Hombergh Richard van den Ham. February 8, 2018 Pieter van den Hombergh Richard van den Ham Fontys Hogeschool voor Techniek en Logistiek February 8, 2018 /FHTenL February 8, 2018 1/16 Collection Zoo The basic collections, well known in programming s

More information

Doubly LinkedList is Symmetrical! LinkedList Efficiency. Monday, April 8, 13. insert insert remove remove remove walk

Doubly LinkedList is Symmetrical! LinkedList Efficiency. Monday, April 8, 13. insert insert remove remove remove walk How Can We Improve the State of Experimental Evaluation in Computer Siene Peter Sweeney IBM Researh, TJ Watson Friday, April 12, 12:00 Kendade 307 1 Doubly LinkedList is Symmetrial! insert insert remove

More information

EPITA Première Année Cycle Ingénieur. Atelier Java - J2

EPITA Première Année Cycle Ingénieur. Atelier Java - J2 EPITA Première Année Cycle Ingénieur marwan.burelle@lse.epita.fr http://www.lse.epita.fr Plan 1 2 A Solution: Relation to ML Polymorphism 3 What are Collections Collection Core Interface Specific Collection

More information

Tha Java Programming Language

Tha Java Programming Language Tha Java Programming Language Kozsik Tamás (2000-2001) kto@elte.hu http://www.elte.hu/~k to/ III. Arrays, collections and other baseclasses Some of the baseclasses Object String StringBuffer Integer, Double,...

More information

The Java Collections Framework and Lists in Java Parts 1 & 2

The Java Collections Framework and Lists in Java Parts 1 & 2 The Java Collections Framework and Lists in Java Parts 1 & 2 Chapter 9 Chapter 6 (6.1-6.2.2) CS 2334 University of Oklahoma Brian F. Veale Groups of Data Data are very important to Software Engineering

More information

EXAMINATIONS 2012 Trimester 1, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS

EXAMINATIONS 2012 Trimester 1, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2012 Trimester 1, MID-TERM TEST COMP103 Introduction

More information

Model Solutions. COMP 103: Test April, 2013

Model Solutions. COMP 103: Test April, 2013 Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 40 minutes

More information

Basicsof programming3. Java collections

Basicsof programming3. Java collections Basicsof programming3 Java collections Java Generics Basics of programming 3 BME IIT, Goldschmidt Balázs 2 Generics Objective: code reuse with generic types Csolution void* malloc(size_t s) casting is

More information

Hashing as a Dictionary Implementation

Hashing as a Dictionary Implementation Hashing as a Dictionary Implementation Chapter 22 Contents The Efficiency of Hashing The Load Factor The Cost of Open Addressing The Cost of Separate Chaining Rehashing Comparing Schemes for Collision

More information

Model Solutions. COMP 103: Test May, 2013

Model Solutions. COMP 103: Test May, 2013 Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 45 minutes

More information

Charlie Garrod Bogdan Vasilescu

Charlie Garrod Bogdan Vasilescu Principles of So3ware Construc9on: Objects, Design, and Concurrency Part 2: Designing (sub-) systems Java Collec9ons design case study Charlie Garrod Bogdan Vasilescu School of Computer Science 1 Administrivia

More information

Generic Programming. *Really* reusable code

Generic Programming. *Really* reusable code Generic Programming *Really* reusable code First, a bit of history Since Java version 5.0, Java has borrowed a page from C++ and offers a template mechanism, allowing programmers to create data structures

More information

Questions and Answers. Q.3) asses is not part of Java's collection framework?explanation:

Questions and Answers.   Q.3) asses is not part of Java's collection framework?explanation: Q.1) $ javac vector.java $ java vector 4 A. [3, 2, 6] B. [3, 2, 8] C. [3, 2, 6, 8] D. [3, 2, 8, 6] ANSWER : [3, 2, 8, 6] $ javac vector.java $ java vector [3, 2, 8, 6] Q.2) Which interface does java.util.hashtable

More information

CS61B Lecture #17. Last modified: Mon Oct 1 13:40: CS61B: Lecture #17 1

CS61B Lecture #17. Last modified: Mon Oct 1 13:40: CS61B: Lecture #17 1 CS61B Lecture #17 Last modified: Mon Oct 1 13:40:29 2018 CS61B: Lecture #17 1 Topics Overview of standard Java Collections classes Iterators, ListIterators Containers and maps in the abstract Amortized

More information

Agenda. Inner classes and implementation of ArrayList Nested classes and inner classes The AbstractCollection class Implementation of ArrayList

Agenda. Inner classes and implementation of ArrayList Nested classes and inner classes The AbstractCollection class Implementation of ArrayList Implementations I 1 Agenda Inner classes and implementation of ArrayList Nested classes and inner classes The AbstractCollection class Implementation of ArrayList Stack and queues Array-based implementations

More information

Collection Interfaces

Collection Interfaces CJ7V2.book Page 85 Wednesday, October 27, 2004 2:32 PM 2 Collections COLLECTION INTERFACES CONCRETE COLLECTIONS THE COLLECTIONS FRAMEWORK ALGORITHMS LEGACY COLLECTIONS Object-oriented programming (OOP)

More information

EXAMINATIONS 2012 MID YEAR. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS

EXAMINATIONS 2012 MID YEAR. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2012 MID YEAR COMP103 Introduction to Data

More information

Notes on access restrictions

Notes on access restrictions Notes on access restrictions A source code file MyClass.java is a compilation unit and can contain at most one public class. Furthermore, if there is a public class in that file, it must be called MyClass.

More information

Algorithms. Produced by. Eamonn de Leastar

Algorithms. Produced by. Eamonn de Leastar Algorithms Produced by Eamonn de Leastar (edeleastar@wit.ie) Collections ± Collections Architecture ± Definition ± Architecture ± Interfaces ± Collection ± List ± Set ± Map ± Iterator ± Implementations

More information

List ADT. Announcements. The List interface. Implementing the List ADT

List ADT. Announcements. The List interface. Implementing the List ADT Announcements Tutoring schedule revised Today s topic: ArrayList implementation Reading: Section 7.2 Break around 11:45am List ADT A list is defined as a finite ordered sequence of data items known as

More information

Important Dates. Game State and Tree. Today s topics. Game Tree and Mini-Max. Games and Mini-Max 3/20/14

Important Dates. Game State and Tree. Today s topics. Game Tree and Mini-Max. Games and Mini-Max 3/20/14 MINI-MAX USING TREES AND THE JAVA COLLECTIONS FRAMEWORK Lecture 16 CS2110 Spring 2014 2 Important Dates. April 10 --- A4 due (Connect 4, minimax, trees) April 15 --- A5 due (Exercises on different topics,

More information

COMP 103 : Test. 2018, Sept 12//(Corrected)

COMP 103 : Test. 2018, Sept 12//(Corrected) Family Name:.............................. Other Names:............................. Student ID:................................ Signature.................................. COMP 103 : Test 2018, Sept 12//(Corrected)

More information

JAVA.UTIL.LINKEDLIST CLASS

JAVA.UTIL.LINKEDLIST CLASS JAVA.UTIL.LINKEDLIST CLASS http://www.tutorialspoint.com/java/util/java_util_linkedlist.htm Copyright tutorialspoint.com Introduction The java.util.linkedlist class operations perform we can expect for

More information

Collections and Maps

Collections and Maps Software and Programming I Collections and Maps Roman Kontchakov / Carsten Fuhs Birkbeck, University of London Outline Array Lists Enhanced for Loop ArrayList and LinkedList Collection Interface Sets and

More information

EXAMINATIONS 2011 Trimester 2, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS

EXAMINATIONS 2011 Trimester 2, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2011 Trimester 2, MID-TERM TEST COMP103 Introduction

More information

ArrayList. Introduction. java.util.arraylist

ArrayList. Introduction. java.util.arraylist ArrayList Introduction In this article from my free Java 8 course, I will be giving you a basic overview of the Java class java.util.arraylist. I will first explain the meaning of size and capacity of

More information

Computer Science II (Spring )

Computer Science II (Spring ) Computer Science II 4003-232-01 (Spring 2007-2008) Week 5: Generics, Java Collection Framework Richard Zanibbi Rochester Institute of Technology Generic Types in Java (Ch. 21 in Liang) What are Generic

More information

EECS 2011 M: Fundamentals of Data Structures

EECS 2011 M: Fundamentals of Data Structures EECS 2011 M: Fundamentals of Data Structures Suprakash Datta Office: LAS 3043 Course page: http://www.eecs.yorku.ca/course/2011m Also on Moodle S. Datta (York Univ.) EECS 2011 W18 1 / 19 Iterators and

More information