Example & Tutorial understanding programming in easy ways.

Simple Example of HashSet class in Java .

import java.util.*;

class Test3{

public static void main(String args[]){

HashSet hs=new HashSet();

hs.add("Hello");

hs.add("My");

hs.add("Java");

hs.add("Hello");

Iterator itr=hs.iterator();

while(itr.hasNext()){

System.out.println(itr.next());

} } }

Output: My
             Java
             Hello

Read More →