Java Collection Tutorial - Java Collections EMPTY_SET


Collections.EMPTY_SET has the following syntax.

public static final Set EMPTY_SET


In the following code shows how to use Collections.EMPTY_SET field.

//from ww w  .  jav  a  m
import java.util.Collections;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
  public static Set getMy(){
    String nullFlag = null;
    if(nullFlag == null){
      return Collections.EMPTY_SET;
    return null;