java.util.Collections.emptyMap() 方法


java.util.Collections.emptyMap() 方法

package com.codingdict;

import java.util.*;

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

      // create an empty map    
      Map<String, String> emptymap = Collections.emptyMap();

      System.out.println("Created empty immutable map: "+emptymap);

      // try to add elements
      emptymap.put("1","value");
   }    
}