Java get the first element of the set

www.lau‮irutt‬.com
Java get the first element of the set
/**
 * @author lautturi.com 
 * Java example: get the 
 */ get the first element of the set in java

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {
		
		Set<Integer> set = new HashSet<>();
		set.add(1);
		set.add(2);
		set.add(3);
		
		Integer firstElement = set.iterator().next();

		System.out.println(firstElement);
	}
}
Created Time:2017-09-26 15:19:30  Author:lautturi