cari

Rumah  >  Soal Jawab  >  teks badan

java - 请问Map map = new HashMap;与Map map = Maps.Hashmap;创建的map对象有什么区别?

天蓬老师天蓬老师2806 hari yang lalu835

membalas semua(2)saya akan balas

  • 巴扎黑

    巴扎黑2017-04-18 10:47:14

    Adakah anda bercakap tentang com.google.common.collect.Maps.newHashMap()?

    balas
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:47:14

    Tiada perbezaan, anda akan tahu selepas melihat kod sumber:

    /**
       * Creates a <i>mutable</i>, empty {@code HashMap} instance.
       *
       * <p><b>Note:</b> if mutability is not required, use {@link
       * ImmutableMap#of()} instead.
       *
       * <p><b>Note:</b> if {@code K} is an {@code enum} type, use {@link
       * #newEnumMap} instead.
       *
       * @return a new, empty {@code HashMap}
       */
      public static <K, V> HashMap<K, V> newHashMap() {
        return new HashMap<K, V>();
      }

    balas
    0
  • Batalbalas