equals(Object o)
引數說明:public static void main(String[] args)throws InterruptedException{ Map map1 = new HashMap(); //定義Map集合物件 map1.put("apple","新鮮的蘋果"); //向集合中新增物件 map1.put("computer","設定優良的計算機"); map1.put("book","堆積成山的圖書"); Map map2 = new HashMap(); map2.put("apple","新鮮的蘋果"); //定義Map集合物件map2 map2.put("computer","設定優良的計算機"); map2.put("book","堆積成山的圖書"); boolean contains = map1.equals(map2); //判斷集合是否相等 if(contains){ System.out.println("兩個Map物件相同"); }else{ System.out.println("這不是兩個相同的Map物件"); } }執行結果如下: