In this example, we will create an empty set using theemptySet()
method.
Source Code
package com.beginner.examples;
import java.util.Collections;
import java.util.Set;
public class EmptySetExample {
public static void main(String a[]){
// use emptySet()
Set set = Collections.emptySet();
System.out.println("Set: " + set);
}
}
Output:
Set: []
References
Imported packages in Java documentation: