Click here to watch in Youtube : https://www.youtube.com/watch?v=PhCu6ZnhTqE&list=UUhwKlOVR041tngjerWxVccwLinkedHashSetExample.java import java.util.LinkedHashSet;
/*
* Example of isEmpty() method.
*/
public class LinkedHashSetExample
{
public static void main( String[] args )
{
LinkedHashSet<String> linkedHashSet = new LinkedHashSet<String>();
System.out.println("linkedHashSet: " + linkedHashSet);
/*
* Returns true if this set contains no elements.
*/
boolean isEmpty = linkedHashSet.isEmpty();
System.out.println("isEmpty : " + isEmpty + "\n");
linkedHashSet.add("Dave");
linkedHashSet.add("Peter");
linkedHashSet.add("Phil");
linkedHashSet.add("Rohit");
linkedHashSet.add("Virat");
System.out.println("linkedHashSet: " + linkedHashSet);
isEmpty = linkedHashSet.isEmpty();
System.out.println("isEmpty : " + isEmpty);
}
}
Output linkedHashSet: []
isEmpty : true
linkedHashSet: [Dave, Peter, Phil, Rohit, Virat]
isEmpty : false