ittimepass.com
Write a program in java to demonstrate HashSet? ⋆ IT TIME PASS
import java.util.*; public class ListHashSet { public static void main(String arg[]) { HashSet ListTreeSet=new HashSet(); System.out.println("Adding Kundan First Time "+ListTreeSet.add("Kundan")); ListTreeSet.add("Suraj"); ListTreeSet.add("Manish"); ListTreeSet.add("Ankit"); System.out.println("Adding Kundan Second Time "+ListTreeSet.add("Kundan")); System.out.println("Total Number In ListTreeSet "+ListTreeSet.size()); Iterator itr=ListTreeSet.iterator(); while(itr.hasNext()) System.out.println(itr.next()); } } Related