0% found this document useful (0 votes)
6 views

Java Collections - Final

Uploaded by

Khalid Ahmad
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Java Collections - Final

Uploaded by

Khalid Ahmad
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 66

Dr. N.

SIVAKUMAR
B.Tech, M.Tech, MHRM, MBA, Ph.D

Professor, CSE
Puducherry Technological University
1
2
3
CSEB.26@PTUNIV.EDU.IN

4
5
6
7
8
9
10
11
12
13
14
15
16
17
Hierarchy
of
Collection
Framework

18
Sorting
• Comparable Interface • Comparator Interface
• Default nature of sorting order • Customized sorting order

19
20
Cursors
• Enumerations • Iterator • ListIterator

21
Collection in Java
• Any group of individual objects which are represented as a single unit is
known as the collection of the objects.
• The Collection interface (java.util.Collection) and Map interface
(java.util.Map) are the two main “root” interfaces of Java collection
classes.

22
23
24
25
26
27
Java ArrayList

• Java ArrayList class uses a dynamic array for


storing the elements.
• It is like an array, but there is no size limit.
• We can add or remove elements anytime.
• So, it is much more flexible than the traditional
array.
• It is found in the java.util package.

28
29
30
31
32
33
• Java LinkedList class uses a doubly linked list to
store the elements. It provides a linked-list data
structure.
• It inherits the AbstractList class and implements
List and Deque interfaces.
• The important points about Java LinkedList are:
Java • Java LinkedList class can contain duplicate
LinkedList elements.
• Java LinkedList class maintains insertion order.
class • Java LinkedList class is non synchronized.
• In Java LinkedList class, manipulation is fast
because no shifting needs to occur.
• Java LinkedList class can be used as a list, stack
or queue.
34
35
36
Java LinkedList example to add elements

37
Java LinkedList example to remove elements

38
Java LinkedList Example to reverse a list of
elements

39
Difference Between ArrayList and LinkedList

40
Example of ArrayList and LinkedList in
Java

41
42
43
Java HashSet Example

44
Java HashSet example ignoring duplicate elements

45
Java HashSet example to remove elements

46
Java HashSet from another Collection

47
48
49
Java TreeMap Example: remove()

50
Java TreeMap Example:
NavigableMap

51
Java Vector

52
53
54
55
JDBC Driver
JDBC Driver is a software component that enables java application to
interact with the database. There are 4 types of JDBC drivers:
1. JDBC-ODBC bridge driver
2. Native-API driver (partially java driver)
3. Network Protocol driver (fully java driver)
4. Thin driver (fully java driver)

56
57
58
59
60
Multithreading
• Multithreading in Java is a process of executing multiple threads
simultaneously.
• A thread is a lightweight sub-process, the smallest unit of processing.
• Java Multithreading is mostly used in games, animation, etc.

61
Thread in java

• A thread is a lightweight
subprocess, the smallest unit
of processing. It is a separate
path of execution.

• Threads are independent. If


there occurs exception in one
thread, it doesn't affect other
threads. It uses a shared
memory area.
62
Life cycle of a Thread (Thread States)
In Java, a thread always exists in any one of the following states. These
states are:
1. New
2. Active
3. Blocked / Waiting
4. Timed Waiting
5. Terminated
63
64
65
Advantages of Java Multithreading
• 1) It doesn't block the user because threads are independent and you can
perform multiple operations at the same time.
• 2) You can perform many operations together, so it saves time.
• 3) Threads are independent, so it doesn't affect other threads if an
exception occurs in a single thread.

66

You might also like