Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
10 views
30 pages
Collection Framework in Java - 20240423 - 110131
java collection
Uploaded by
sudhakar murugesan
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Collection Framework in java - 20240423_110131 (1) For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
10 views
30 pages
Collection Framework in Java - 20240423 - 110131
java collection
Uploaded by
sudhakar murugesan
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Collection Framework in java - 20240423_110131 (1) For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Collection Framework in java - 20240423_110131 (1) For Later
You are on page 1
/ 30
Search
Fullscreen
e Call Us: 011-65164822 & COLLECTION FRAMEWORK CPD TECHNOLOGIES Add:- Block C 9/8, Sector -7, Rohini , Delhi-110085, India www.cpd-india.com = www.blog.cpd-india.com @COLLECTION FRAMEWORK The collections framework is a unified architecture for representing and manipulating collections, enabling them to be manipulated independently of the details of their representation. It reduces programming effort while increasing performance. It enables interoperability among unrelated APIs, reduces effort in designing and learning new APIs, and fosters software reuse. The framework is based on more than a dozen collection interfaces. It includes implementations of these interfaces and algorithms to manipulate them.CONTENTS ° What is Collection? © Collections Framework © Collections Hierarchy © Collections Implementations ° Set © List ° MapOBJECTIVES © Define a collection © Describe the collections framework ° Describe the collections hierarchy ° Demonstrate each collection implementationWHAT IS A COLLECTION? ° A Collection (also known as container) is an object that contains a group of objects treated as a single unit. © Any type of objects can be stored, retrieved and manipulated as elements of collections.COLLECTIONS FRAMEWORK Collections Framework is a unified architecture for managing collections Main Parts of Collections Framework \. Interfaces Core interfaces defining common functionality exhibited by collections 1. Implementations Conerete classes of the core interfaces providing data structures |. Operations Methods that perform various operations on collectionsCOLLECTIONS FRAMEWORK INTERFACES Core Interface Description Collection specifies contract that all collections should implement Set defines functionality for a set of unique elements SortedSet defines functionality for a set where elements are sorted List defines functionality for an ordered list of non- unique elements Map defines functionality for mapping of unique keys to values SortedMap defines functionality for a map where its keys are sortedCOLLECTIONS FRAMEWORK IMPLEMENTATIONS HashSet ArrayList HashMap LinkedHashSet lLinkedList LinkedHashMap TreeSet Vector Hashtable ree Map Note: Hashtable uses a lower-case “ @OPERATIONS Basic collection operations: © Cheek if collection is empty © Check if an object exists in collection. © Retrieve an object from collection © Add object to collection © Remove object from collection © Iterate collection and inspect each object © Each operation has a corresponding method implementation for each collection typeCOLLECTIONS CHARACTERISTICS ° Ordered © Elements are stored and accessed in a specific order © Sorted © Elements are stored and accessed in a sorted order ° Indexed © Elements can be accessed using an index © Unique © Collection does not allow duplicates aITERATOR © An iterator is an object used to mark a position in a collection of data and to move from item to item within the collection Syntax: Iterator
=
.iterator();COLLECTIONS HIERARCHY SET AND LIST TEIGUG 4 kop loprente: __ Set L List | 4 impiements extends implements es SortedSet | seams implements LinkedHashSet TreeSet Linkosibist VectorCOLLECTIONS HIERARCHY MAPCOLLECTION IMPLEMENTATIONS List : Lists of things (classes that implement List) Set : Unique things (classes that implement Set) Map : Things with a unique ID (classes that implement Map) |LIST |= = =) A List cares about the index. ArrayList Vector LinkedListLIST IMPLEMENTATIONS ARRAY LIST import java.util ArrayList; public class MyArrayList ( public static void main(String args{ 1) { ArrayList alist = new ArrayList ( ); alist.add(new String("0ne")) ; alist.add(new String(™wo")) ; alist add(new String("Three")}; System.out.printin(alist.get (0): System.out .printin(alist.get (1)); System.out.printin(alist.get(2)):LIST IMPLEMENTATIO VECTOR import java.util. Vector: public class MyVector { public static void main(String argal ]) { Vector vecky = new Vecter( }; vecky.add(new Integer (1)); vecky-add(new Integer (2)) ; vacky.add(new Integer (3)) ; for(int x=0; x<3; xtt) ( System. out-printIn(vecky.get (x)); )LIST IMPLEMENTATIONS LINKED LIST import java.util LinkedList; public class MyLinkedList ( public static void main(String args[ 1) { Linkedbist link = new Linkedbist( ); Link. add (new Double (2.0); Link-addLast (new Double (3.0)) 7 Link.addPirst (new Double(1.0)) Object array[ ] = link. toArray( ); for (int x80; x<3; xt) ( System. out .printin (array (x) j ,SET A Set cares about uniqueness, it doesn’t allow duplicates. HashSet LinkedHashSet TreeSetSET IMPLEMENTATIO. HASH SET import java.uedl.*; public class MyHashset ( public static void main(String args 1) { HashSet hash = new HashSet( ); hash.add("a") hash.add ("b") ; hash. hash. Iterator iterator = hash.iterator( ); while (iterator.hasNext( )) { System.out.printin(iterator.next( ));SET IMPLEMENTATIONS LINKED HASH SET import java.util.LinkedRashset: public class MyLinkedHashset ( public static void main(String axgsf 1) { LinkedHashSet lhs = new LinkedHashSet(); lbs add (new String("One")) ; ths. add (now String("Two")) : Lbs add (new String("Thres")) ; object array[] = 1hs.toarray( } for (int x80; <3; xt) ( System.out .printin (array (x)) ; ,T IMPLEMENTATIONS TREE SET public class MyTreeset { public static void main(String args[ 1) { TreeSet tree = new Treeset(); tree.add (“Jody”) ; tree.add("Remiel") ; tree.add ("Reggie") tree.add ("Philippe") ; Iterator iterator = tree.iterator( ); while (iterator.hasNext( )) { System.out.printin(iterator.next( ).toString( }); ,key “Pr value “Mark” “John” “Luke” A Map cares about unique identifiers.MAP IMPLEMENTATIONS HASH MAP import java.utdl.HasnMap; public class MyHashMap { public static void main(String argsl 1) { HashMap map = new HashMap( ) map. put ("name", "Jody") ; map.put("id", new Integer (446)): map.put("address", "Manila"); System.out.printin(*Name: " + map.get("name")) ; System.out.printin("ID: " + map.get("id")); System.out.printin("Address: “ + map.get("address")):AP IMPLEMENTATIONS HASH TABLE import java.utilHashtable: public class MyHashtable { public static void main(String args{ 1) { Hashtable table = new Hashtable( ); table.put("name", "Jody") ; table.put("id", new Integer (1001)); table.put("address", new String("Manila")); System.out.printin(*Table of Contents:” + table) ;MAP IMPLEMENTATIONS LINKED HASH MAP import java.util.*; public class MyLinkedHashMap ( public static void main(String arga[ }) { int imum = 0: Linked#ashMap myMap = new LinkedHashMap( ); myMap.put ("name", "Jody") ; myMap . put | , new Integer (446) ); myMap.put "address", "Manila") ; myMap.put("type", "Savings"); Collection values Iterator iterator = myMap.values( ); = values.dterator( ); while(iterator.hasNext()) { System.out.printin(iterator.next( )); ,MAP IMPLEMENTATIONS TREE MAP import java.util.*; public class MyTreeMap ( public static void main(String args{]) ( TreeMap treeMap = new TreeMap( ); treeMap.put ("name", “Jody") : treeMap.put("id", new Integer (446)) ; treeMap.put "address", "Manila"); Collection values = treeMap.values() Iterator iterator = values.iterator( ); System, out printin("Printing the VALUES...."); while (iterator.hasNext()) { System.out.println(iterater.next( )); bCOLLECTION CLASSES SUMMARY Ordered cary ET HashMap Hashtable TreeMap Sorted By natural order or custom comparison rules LinkedHashMap x By insertion order or No last access order HashSet x No No TreeSet x Sorted By natural order or ‘custom comparison rules LinkedHashSet x By insertion order or No last access order ArrayList X By index Vector X — By index LinkedList X__ By index NoKEY POINTS Collections Framework contains: Interfaces » Implementations » Operations A list cares about the index. A set cares about uniqueness, it does not allow duplicates. A map cares about unique identifiers.THANK YOU CPD TECHNOLOGIES Block C 9/8, Sector -7, Rohini, Delhi-110085, India Landmark: Near Rohini East Metro Station, Opposite Metro Pillar No-397 Telephone: 011-65164822 Mobile: +91- 8860352748 Email:
[email protected]
You might also like
Java Collection Framework
PDF
No ratings yet
Java Collection Framework
21 pages
Ch1 Collections
PDF
No ratings yet
Ch1 Collections
31 pages
Java U 5
PDF
No ratings yet
Java U 5
61 pages
Collections Framework - List, Set, Map.
PDF
No ratings yet
Collections Framework - List, Set, Map.
25 pages
Collections
PDF
No ratings yet
Collections
76 pages
Collections Notes
PDF
No ratings yet
Collections Notes
10 pages
Unit 5
PDF
No ratings yet
Unit 5
61 pages
Unit 4 (JP)
PDF
No ratings yet
Unit 4 (JP)
70 pages
Collection Framework 1
PDF
No ratings yet
Collection Framework 1
38 pages
2-Java CollectionFramework 10b
PDF
No ratings yet
2-Java CollectionFramework 10b
54 pages
Adv. P Chapter Six
PDF
No ratings yet
Adv. P Chapter Six
53 pages
Collections Generics
PDF
No ratings yet
Collections Generics
58 pages
Chapter 4 Collections
PDF
No ratings yet
Chapter 4 Collections
32 pages
Unit 4
PDF
No ratings yet
Unit 4
60 pages
Java Collection Framework
PDF
No ratings yet
Java Collection Framework
23 pages
Chapter 1 - Collections and Generics
PDF
No ratings yet
Chapter 1 - Collections and Generics
48 pages
Collections
PDF
No ratings yet
Collections
43 pages
Java Collections
PDF
No ratings yet
Java Collections
29 pages
Collections & ArrayList - 1
PDF
No ratings yet
Collections & ArrayList - 1
45 pages
Unit IV Collections1
PDF
No ratings yet
Unit IV Collections1
95 pages
Collections in Java
PDF
No ratings yet
Collections in Java
19 pages
Collection Framework
PDF
No ratings yet
Collection Framework
17 pages
Lecture 16 - Java Collections API
PDF
No ratings yet
Lecture 16 - Java Collections API
68 pages
Chapter 4 Java Collections
PDF
No ratings yet
Chapter 4 Java Collections
24 pages
Unit 4 Notes
PDF
No ratings yet
Unit 4 Notes
12 pages
Java JavaCollectionsFramework BW
PDF
No ratings yet
Java JavaCollectionsFramework BW
52 pages
Java Unit 4
PDF
No ratings yet
Java Unit 4
9 pages
Oop Lecture 08
PDF
No ratings yet
Oop Lecture 08
24 pages
The Java Collections Framework: Praveen Raj R (Mark Education Academy)
PDF
No ratings yet
The Java Collections Framework: Praveen Raj R (Mark Education Academy)
40 pages
5.collections Generic
PDF
No ratings yet
5.collections Generic
16 pages
Collections
PDF
No ratings yet
Collections
12 pages
Unit 3-2
PDF
No ratings yet
Unit 3-2
24 pages
Lecture 9-10
PDF
No ratings yet
Lecture 9-10
47 pages
Collection Framework
PDF
No ratings yet
Collection Framework
10 pages
Unit-4 - OOPS With Java
PDF
No ratings yet
Unit-4 - OOPS With Java
8 pages
Collection:-: Interfaces
PDF
No ratings yet
Collection:-: Interfaces
10 pages
Java Collection Framework: Version March 2009
PDF
No ratings yet
Java Collection Framework: Version March 2009
71 pages
Chapter 6
PDF
No ratings yet
Chapter 6
27 pages
Java Collection Framework
PDF
No ratings yet
Java Collection Framework
13 pages
Java Collections Framework
PDF
No ratings yet
Java Collections Framework
7 pages
Java UNIT-5
PDF
No ratings yet
Java UNIT-5
6 pages
Oop l27 - l28 Collections
PDF
No ratings yet
Oop l27 - l28 Collections
21 pages
Collection: Java Collections Framework Has Following Benefits: 1
PDF
No ratings yet
Collection: Java Collections Framework Has Following Benefits: 1
12 pages
Java Collection Framework
PDF
No ratings yet
Java Collection Framework
6 pages
Chapter 1 - Collections and Generics
PDF
No ratings yet
Chapter 1 - Collections and Generics
48 pages
Java Collections and Generics: - Prashant Kumar
PDF
No ratings yet
Java Collections and Generics: - Prashant Kumar
48 pages
w05 Collections Curs
PDF
No ratings yet
w05 Collections Curs
48 pages
UNIT - IV - Syllabus The Collections Framework (Java - Util)
PDF
No ratings yet
UNIT - IV - Syllabus The Collections Framework (Java - Util)
24 pages
Defined Manner.: Collections Are Nothing But Group of Objects Stored in Well
PDF
No ratings yet
Defined Manner.: Collections Are Nothing But Group of Objects Stored in Well
5 pages
Softeng - Polito.it Slides 07-JavaCollections
PDF
No ratings yet
Softeng - Polito.it Slides 07-JavaCollections
71 pages
Collections in Java
PDF
No ratings yet
Collections in Java
16 pages
Collection Presentations
PDF
No ratings yet
Collection Presentations
18 pages
CS 602 Collections: Arathi Bhandari
PDF
No ratings yet
CS 602 Collections: Arathi Bhandari
24 pages
Class 32: The Java® Collections Framework: Introduction To Computation and Problem Solving
PDF
No ratings yet
Class 32: The Java® Collections Framework: Introduction To Computation and Problem Solving
17 pages
Java Collections Framework
PDF
No ratings yet
Java Collections Framework
6 pages
Limitations of Object Arrays: Collection Framework in Java
PDF
No ratings yet
Limitations of Object Arrays: Collection Framework in Java
18 pages
Java Collections Framework: Colecciones
PDF
No ratings yet
Java Collections Framework: Colecciones
7 pages