請看下面的程序即可:
public class MapTest { public static void main(String[] args){ Map map = new HashMap(); //定義Map集合對象 System.out.println("Map集合的isEmpty方法返回值是:"+map.isEmpty()); map.put("apple","新鮮的蘋果"); System.out.println("Map集合的isEmpty方法返回值是:"+map.isEmpty()); } }
結果:
Map集合的isEmpty方法返回值是:true
Map集合的isEmpty方法返回值是:false