Java set get the first element

www.laut‮.irut‬com
Java set get the first element
/**
 * @author lautturi.com 
 * Java example:  how to 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 = null;
		while(!set.isEmpty()) {
			firstElement= set.iterator().next();
			break;
		}

		System.out.println(firstElement);
	}
}

output:

1
Created Time:2017-09-26 15:20:16  Author:lautturi