文章詳情頁
java - 請問Map map = new HashMap;與Map map = Maps.Hashmap;創(chuàng)建的map對象有什么區(qū)別?
瀏覽:113日期:2024-02-17 15:51:14
問題描述
問題解答
回答1:你說的是com.google.common.collect.Maps.newHashMap()嗎?
回答2:沒什么區(qū)別,你看下源碼就知道了:
/** * 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>(); }
標(biāo)簽:
java
相關(guān)文章:
1. 引入traits后,為什么index得是空的呢?2. java - 如何理解“不要通過共享內(nèi)存來通信,而應(yīng)該通過通信來共享內(nèi)存”?3. javascript - 如何在NW.JS中使用Node自動重啟進(jìn)程?4. javascript - table固定尾行,有人寫過嗎?5. gulp-ruby-sass編譯出來的文件有錯6. dockerfile - docker-compose啟動lnmp失敗?7. 為什么學(xué)習(xí)PHP8. javascript - 使用node.js的ws模塊不斷地向客戶端發(fā)送消息,應(yīng)該如何不斷地去觸發(fā)“發(fā)送”這個動作9. javascript - 為什么會打印兩次啊?10. angular.js使用$resource服務(wù)把數(shù)據(jù)存入mongodb的問題。
排行榜

熱門標(biāo)簽