Java Collection Tutorial - Java Collections EMPTY_SET








Syntax

Collections.EMPTY_SET has the following syntax.

public static final Set EMPTY_SET

Example

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

//from ww w  .  jav  a 2s.co  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;
  }
}