12:51 am - Thursday July 27, 2017

HashSet example program for Iterator iterator()

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:HastSet example program for Iterator iterator()

 */

import java.util.HashSet;
import java.util.Iterator;

public class HastSetIterator

{

	public static void main(String args[]) {

		HashSet newset = new HashSet(); // create hash set

		newset.add("Kingsley");
		newset.add("Pradeep"); // adding elements hash set
		newset.add("Kathik");

		Iterator iterator = newset.iterator(); // creating an iterator

		while (iterator.hasNext()) { // checking values
			System.out.println("Value: " + iterator.next() + " ");
		}

	}

}

Output

Value: Kingsley
Value: Kathik
Value: Pradeep

BACK

Filed in: Z-A All Java Codes

Comments are closed.