java.util.Collections.emptySet() 方法


java.util.Collections.emptySet() 方法

package com.codingdict;

import java.util.*;

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

      // create an empty set    
      Set emptyset = Collections.emptySet();

      System.out.println("Created empty immutable set: "+emptyset);  

      // try to add elements
      emptyset.add("Adding");
   }    
}