Read Book Java How To Program 9th Edition Ppt ? - covid19.gov.gd
off not discover the pronouncement Java How To Program 9th Edition Ppt that you expressions String handling The Collections Framework Networking Event ...
Présentation PowerPoint
13 déc. 2021 Structures fondamentales du langage java. 3. les concepts de la programmation orienté objet java. 4. Les tableaux et les collections en java ...
Java Collection Framework
Generic collections. ? From Java 5 all collection interfaces and classes have been redefined as. Generics. ? Use of generics lead to code that is.
Java How To Program 9th Edition Ppt
Getting the books Java How To Program 9th Edition Ppt now is not type of challenging means. You could not single-handedly going behind book collection or
(Microsoft PowerPoint - Japanfs Response Earthquake Central
On 27th May 2006 an earthquake of m agnitude 6.3 caused heavy dam ages in. Yogyakarta and Central Java w ith m ore than 5
Introduction to the Java collections Framework • Lists • Sets • Maps
The Java Collections Framework is a library of classes and interfaces for working with collections of objects. A collection is an object which can store
(Microsoft PowerPoint - inf111-h12-paradigme-OO.ppt [Mode de
Un programme Java utilise un ensemble de classes. ? Les classes sont regroupées dans un ou plusieurs packages. ? Une classe regroupe un ensemble
Les bases de la programmation orientée objet avec Java
Compiled from "HelloWorld.java" public class HelloWorld extends java.lang.Object{ public HelloWorld();. Code: 0: aload_0. 1: invokespecial.
Présentation PowerPoint
[Pat08] Java Persistence et Hibernate d'Anthony Patricio
Présentation PowerPoint
[BK07] Java Persistence with Hibernate Revised Edition of variable d'instance de type collection d'objets (multiplicité 1..* ou *).
[PDF] Java Collection Framework
Generic collections ? From Java 5 all collection interfaces and classes have been redefined as Generics ? Use of generics lead to code that is
[PDF] Introduction to the Java collections Framework • Lists • Sets • Maps
The Java Collections Framework is a library of classes and interfaces for working with collections of objects A collection is an object which can store other
[PPT] Java Collections
Java Collections Framework The Java language API Collection Interfaces - Represent different types of collections such as sets lists and maps
[PDF] The Java Collections Framework - RIT
The Java Collections Framework Definition Set of interfaces abstract and concrete classes that define common abstract data types in Java
Java collections - SlideShare
This framework has several useful classes which have tons of useful functions which makes a programmer task super easy Almost all collections in Java are
Java Collections - SlideShare
Collection Framework Handled By Dr T Abirami Associate Professor Department of IT Kongu Engineering College Perundurai What is a Framework?
[PPT] Java for Beginners – 3 Collections
Collections Overview Collection classes in Java are containers of Objects which by polymorphism can hold any class that derives from Object (which is
JAVA Collections frame work ppt - DOKUMENTIPS
COLLECTIONS The main java collections are ListSet and Map LIST the list store the elements in sequential form It stores the elements in the order they
Collection Framework PDF Class (Computer Programming) - Scribd
Collection Framework ppt - Free download as Powerpoint Presentation ( ppt) PDF File Java comes with a group of generic collection classes that grow
Chapter 18 Java Collections Framework - ppt download - SlidePlayer
A collection is a container object that represents a group of objects often referred to as elements The Java Collections Framework supports three types of
Java Collection Framework
Version March 2009
2Framework
Interfaces (ADT, Abstract Data Types)
Implementations (of ADT)
Algorithms (sort)
java.util.*
Java 5 released!
Lots of changes about collections
3Interfaces
Collection
SetList
Map
SortedSet
SortedMap
Group containers
Associative containers
Queue
Iterable
4 Implementations
TreeSet
TreeMapArray
ListLinked
ListHashMap
Linked
HashMap
Linked
HashSet
HashSet
Map
Sorted
Map
Collection
SetList
Sorted
Set
Queue
Priority
Queue 5Internals
LinkedList
Linked list
LinkedHashMapTreeMapHashMapMap
ArrayListList
LinkedHashSet TreeSetHashSetSet
Hash table
Linked list
Balanced
treeResizable
array Hash table interface data structure classes 6Collection
Groupof elements (referencesto objects)
It is not specified whether they are
Ordered / not ordered
Duplicated / not duplicated
Following constructors are common to all
classes implementing CollectionT()
T(Collection c)
7Collection interface
int size()
boolean isEmpty()
boolean contains(Object element)
boolean containsAll(Collection c)
boolean add(Object element)
boolean addAll(Collection c)
boolean remove(Object element)
boolean removeAll(Collection c)
void clear()
Object[] toArray()
Iterator iterator()
8Collection example
Collection persons =
new LinkedListSystem.out.println( persons.size() );
Collection copy =
new TreeSetPerson[] array = copy.toArray();
System.out.println( array[0] );
9 MapAn object that associates keys to values
HBJB 661 ҧ 3HUVRQ
Keys and values must be objects
Keysmust be unique
Only one value per key
Following constructors are common to all
collection implementersT()
T(Map m)
10Map interface
Object put(Object key, Object value)
Object get(Object key)
Object remove(Object key)
boolean containsKey(Object key)
boolean containsValue(Object value)
public Set keySet()
public Collection values()
int size()
boolean isEmpty()
void clear()
11Map example
MapPerson bob = people.get³5%7*51´
if( bob == null)6\VPHPBRXPBSULQPOQ ³1RP IRXQG´
int populationSize = people.size(); 12Generic collections
From Java 5, all collection interfaces
and classes have been redefined asGenerics
Use of generics lead to code that is
safer
more compact
easier to understand
equally performing
13Generic list -excerpt
public interface ListIterator iterator();
public interface IteratorE next();
booleanhasNext(); 14Example
Using a list of Integers
Without generics ( ArrayListlist )
list.add(0, new Integer(42));intn= ((Integer)(list.get(0))).intValue();With generics ( ArrayList list )
list.add(0, new Integer(42));intn= ((Integer)(list.get(0))).intValue(); + autoboxing( ArrayList list )
list.add(0,new Integer(42));inttotal = list.get(0).intValue(); Group containers
(Collections)CollectionSetList
SortedSet
Queue
16 List Can contain duplicateelements
Insertion orderis preserved
User can define insertion point
Elements can be accessed by position
Augments Collection interface
17List additional methods
Object get(int index)
Object set(int index, Object element)
void add(int index, Object element)
Object remove(int index)
boolean addAll(int index, Collection c)
int indexOf(Object o)
int lastIndexOf(Object o)
List subList(int fromIndex, int toIndex)
18List implementations
ArrayList
get(n)
Constant time
Insert (beginning)
and delete while iteratingLinear
LinkedList
get(n)
Linear time
Insert (beginning)
and delete while iteratingConstant
19List implementations
ArrayList
ArrayList()
ArrayList(int initialCapacity)
ArrayList(Collection c)
void ensureCapacity(int minCapacity)
LinkedList
void addFirst(Object o)
void addLast(Object o)
Object getFirst()
Object getLast()
Object removeFirst()
Object removeLast()
20Example I
LinkedListll =
new LinkedListExample II
Car[] garage = new Car[20];
garage[0] = new Car(); garage[1] = new ElectricCar(); garage[2] = new ElectricCar(); garage[3] = new Car(); for(int i=0; iListgarage = new ArrayList(20);
garage.set( 0, new Car() ); garage.set( 1, new ElectricCar() ); garage.set( 2, new ElectricCar() ); garage.set( 3, new Car()); for(int i; iExample III
List l = new ArrayList(2); // 2 refs to null
l.add(new Integer(11)); // 11 in position 0 l.add(0, new Integer(13)); // 11 in position 1 l.set(0, new Integer(20)); // 13 replaced by 20 l.add(9, new Integer(30)); // NO: out of bounds l.add(new Integer(30)); // OK, size extended 23Queue
Collection whose elements have an
order (not and ordered collection though
Defines a headposition where is the
first element that can be accessedpeek()
poll()
24Queue implementations
LinkedList
head is the first element of the list
FIFO: Fist-In-First-Out
PriorityQueue
head is the smallest element
25Queue example
Queue fifo =
new LinkedListQueue pq =
new PriorityQueueSystem.out.println(fifo.peek()); // 3
System.out.println(pq.peek());// 1
26Set
Contains no methods other than those
inherited from Collectionadd()has restriction that no duplicate
elementsare allowede1.equals(e2) == false
e1,e2Iterator
The elements are traversed in no
particular orderThe equals() Contract
It is reflexive: x.equals(x) == true
It is symmetric: x.equals(y) == y.equals(x)
It is transitive: for any reference values x, y, and z, if x.equals(y) == true AND y.equals(z) == true => x.equals(z) == true It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true (or false), provided that no information used in equals comparisons on the object is modified. x.equals(null) == false hashCodeThe hashCode() contract
The hashCode() method must consistently
return the same int, if no information used in equals() comparisons on the object is modified.If two objects are equal for equals() method,
then calling the hashCode() method on the two objects must produce the sameintegerresult.If two objects are unequal for equals() method,
then calling the hashCode() method on the two objects MAY produce distinct integer results. producing distinct intresults for unequal objects may improve the performance of hashtablesHashCode()
equals() and hashcode()equals() and hashCode() are bound together by
a joint contract that specifies if two objects are considered equal using the equals() method, then they must have identical hashcodevalues.To be truly safe:
If override equals(), override hashCode()
Objects that are equals have to return identical hashcodes. 32SortedSet
No duplicate elements
Iterator
The elements are traversed according to the
natural ordering(ascending)Augments Set interface
Object first()
Object last()
SortedSet headSet(Object toElement)
SortedSet tailSet(Object fromElement)
SortedSet subSet(Object from, Object to)
33Set implementations
HashSetimplements Set
Hash tables as internal data structure
(faster)LinkedHashSetextends HashSet
Elements are traversed by iterator
according to the insertion orderTreeSetimplements SortedSet
R-B trees as internal data structure
(computationally expensive) 34Note on sorted collections
Depending on the constructor used
they require different implementation of the custom orderingTreeSet()
Natural ordering (elements must be
implementations of Comparable)TreeSet(Comparator c)
Ordering is according to the comparator
rules, instead of natural orderingAssociative containers
(Maps)Map
SortedMap
36SortedMap
The elements are traversed according
PR POH NH\V· natural ordering
(ascending)Augments Map interface
SortedMap subMap(K fromKey, K toKey)
SortedMap headMap(K toKey)
SortedMap tailMap(K fromKey)
K firstKey()
K lastKey()
37Map implementations
Analogous of Set
HashMapimplements Map
No order
LinkedHashMapextends HashMap
Insertion order
TreeMapimplements SortedMap
Ascending key order
38HashMap
Get/set takes constant time(in case of
no collisions)Automatic re-allocation when load
factor reachedConstructor optional arguments
load factor(default = .75)
initial capacity(default = 16)
39Using HashMap
Map students =
new HashMapQHR 6PXGHQP³123´³-RH 6PLPO´
Student s = students.get³123´
for(Student si: students.values()){Iterators
41Iterators and iteration
A common operation with collections
is to iterate over their elementsInterface Iterator provides a
transparent means to cycle through all elements of a CollectionKeeps track of last visitedelement of
the related collectionEach time the current element is
queried, it moves on automatically 42Iterator interface
boolean hasNext()
Object next()
void remove()
quotesdbs_dbs14.pdfusesText_20[PDF] java collections hands on
[PDF] java collections interview questions pdf
[PDF] java collections lecture notes
[PDF] java collections notes by durga sir
[PDF] java collections problems
[PDF] java collections programming exercises
[PDF] java collections tutorialspoint pdf
[PDF] java collections w3resource
[PDF] java compareto custom object
[PDF] java compareto null object
[PDF] java compareto nullable objects
[PDF] java compareto object method
[PDF] java compareto se8
[PDF] java compareto two objects