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.


//w w  w. j  ava 2  s .com
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;
  }
}