Collections , a utility class in Collections framework , provided six factory methods , for each
(remember ther is no Queue)
lets check with the example for set
public class Child {
public static void main(String[] args){
Set<Integer> s = new HashSet<Integer>();
s.add(1);
s.add(2);
s.add(3);
s.add(4);
s.add(5);
System.out.println(s);
Set s1 = Collections.unmodifiableSet(s);
s1.add(6);
}
}
if we try to run this , then we will get below exception
Collection
, List
,Map
, SortedMap,Set
, ,SortedSet
.(remember ther is no Queue)
lets check with the example for set
public class Child {
public static void main(String[] args){
Set<Integer> s = new HashSet<Integer>();
s.add(1);
s.add(2);
s.add(3);
s.add(4);
s.add(5);
System.out.println(s);
Set s1 = Collections.unmodifiableSet(s);
s1.add(6);
}
}
if we try to run this , then we will get below exception
java.lang.UnsupportedOperationException
No comments:
Post a Comment