Java Collections EMPTY_LIST

Syntax

Collections.EMPTY_LIST has the following syntax.

public static final List EMPTY_LIST

Example

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


import java.util.Collections;
import java.util.List;
/*from w ww  .j  a  v a  2 s.  c o  m*/
public class Main {

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