Professional Documents
Culture Documents
Module 4.1 - Java Programming
Module 4.1 - Java Programming
Module 4.1 - Java Programming
Serialization
• Serialization in Java is a mechanism of writing
the state of an object into a byte-stream.
Example
import java.util.*;
public class TestJavaCollection9{
public static void main(String args[]){
//Creating and adding elements Output:
TreeSet<String> set=new TreeSet<String>();
Ajay
set.add("Ravi"); Ravi
set.add("Vijay");
Vijay
set.add("Ravi");
set.add("Ajay");
//traversing elements
Iterator<String> itr=set.iterator();
while(itr.hasNext()){
System.out.println(itr.next());
}
}
LinkedHashSet
• LinkedHashSet maintains a linked list of the
entries in the set, in the order in which they
were inserted.
Map
A map contains values on the basis of key, i.e.
key and value pair. Each key and value pair is
known as an entry. A Map contains unique keys.