java.util.Collections.emptyList() 方法


java.util.Collections.emptyList() 方法

package com.codingdict;

import java.util.*;

public class CollectionsDemo {
   public static void main(String args[]) {

      // create an empty list    
      List<String> emptylst = Collections.emptyList();

      System.out.println("Created empty immutable list: "+emptylst);

      // try to add elements
      emptylst.add("A");
      emptylst.add("B");
   }    
}