3:06 pm - Saturday September 26, 2657

Collections Example program for checkedSet(Set s, Class type)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**
*@author: candidjava.com
*@description: Collections Example program for checkedSet(Set s, Class type)
*/

import java.util.HashSet;
import java.util.Set;
import java.util.Collections;

public class Sets1 {
public static void main(String[] args) {
Set<Integer> setInt = new HashSet<Integer>();
setInt = Collections.checkedSet(setInt, Integer.class);
setInt.add(5);
setInt.add(6);
Set set = setInt;

set.add(4);
set.add(5);
setInt.remove(7);
for (Integer i : setInt) {
System.out.println(i);
}
}

}

Output
4
5
6

BACK

Filed in: Z-A All Java Codes

Comments are closed.