Master java skills

LinkedHashSet in Java

LinkedHashSet class also implements Set interface

LinkedHashSet maintains insertion order of elements. It means elements will be retrieved in the same order in which they have been added.

package com.javatrainingschool;

import java.util.LinkedHashSet;
import java.util.Set;

public class LinkedHashSetExample {

	public static void main(String[] args) {
		
		Set<Integer> set = new LinkedHashSet<Integer>();
		set.add(200);
		set.add(200);
		set.add(100);
		set.add(300);
		set.add(300);
		set.add(400);
		
		System.out.println(set);
	}
}
Output:
[200, 100, 300, 400]