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

Java's Collection Framework: Technical Team

The document discusses Java's Collections Framework, which provides a unified architecture for representing and manipulating collections through interfaces, implementations, and algorithms. The interfaces define common operations on collections, implementations provide concrete collection classes, and algorithms perform useful computations like searching and sorting that can be used on different collection types. The framework reduces programming effort and increases performance by providing useful data structures, collections, and algorithms that don't need to be written from scratch.

Uploaded by

gdskumar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Java's Collection Framework: Technical Team

The document discusses Java's Collections Framework, which provides a unified architecture for representing and manipulating collections through interfaces, implementations, and algorithms. The interfaces define common operations on collections, implementations provide concrete collection classes, and algorithms perform useful computations like searching and sorting that can be used on different collection types. The framework reduces programming effort and increases performance by providing useful data structures, collections, and algorithms that don't need to be written from scratch.

Uploaded by

gdskumar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Java's Collection Framework

Presented By
Technical Team
Spark Whiz Technical Team
Contents
• What is a Collections Framework
• Collection Interfaces
• Implementations
• Collection Algorithms
• Example
• Advantages

Spark Whiz Technical Team


Collection Framework
– A collections framework is a unified architecture
for representing and manipulating collections. It
has:
• Interfaces: abstract data types representing collections
• Implementations: concrete implementations of the
collection interfaces
• Algorithms: methods that perform useful
computations, such as searching and sorting
– These algorithms are said to be polymorphic: the same
method can be used on different implementations

Spark Whiz Technical Team


Collection interfaces

Spark Whiz Technical Team


Implementations
– A collection class
• implements an ADT as a Java class
• implements all methods of the interface
• selects appropriate instance variables
• can be instantiated
– Java implements interfaces with
• List: ArrayList, LinkedList, Vector
• Map: HashMap, TreeMap
• Set: TreeSet, HashSet

Spark Whiz Technical Team


Algorithms
– Java has polymorphic algorithms to provide
functionality for different types of collections
• Sorting (e.g. sort)
• Shuffling (e.g. shuffle)
• Routine Data Manipulation (e.g. reverse, addAll)
• Searching (e.g. binarySearch)
• Composition (e.g. frequency)
• Finding Extreme Values (e.g. max)

Spark Whiz Technical Team


Example
//Convert an ArrayList into an Array
Import java.util.*;
class ArrayListToArray{
public static void main(String[] args){
//Create an Array List
ArrayList<Integer> al=new ArrayList<Integer>();
al.add(1);
al.add(2);
al.add(3);
al.add(4);
System.out.println(“Contents of al: “+al);
}
}
Output: Contents of al: [1, 2, 3, 4]
Spark Whiz Technical Team
Example
import java.util.*;
public class FindDups {
public static void main(String[] args) {
Set<String> uniques = new HashSet<String>();
Set<String> dups = new HashSet<String>();
for (String a : args)
if (!uniques.add(a))
dups.add(a);
// Destructive set-difference
uniques.removeAll(dups);
System.out.println("Unique words: " + uniques);
System.out.println("Duplicate words: " + dups);
} } //when run with arguments “i came i saw i left”

OUTPUT: Unique words: [left, saw, came]


Duplicate words: [i] Spark Whiz Technical Team
Advantages
• Reduces programming effort by providing useful
data structures and algorithms so you don't have to
write them yourself.
• Increases performance by providing high-
performance implementations of useful data
structures and algorithms.
• Provides interoperability between unrelated APIs by
establishing a common language to pass collections
back and forth

Spark Whiz Technical Team


Cont..
• Reduces the effort required to learn APIs by
eliminating the need to learn multiple ad hoc
collection APIs.
• Reduces the effort required to design and
implement APIs by eliminating the need to produce
ad hoc collections APIs.
• Fosters software reuse by providing a standard
interface for collections and algorithms to
manipulate them.

Spark Whiz Technical Team


COMMENTS

Spark Whiz Technical Team


THAN Q

Spark Whiz Technical Team

You might also like