weakhashmap_Java WeakHashMap putAll()方法與示例

weakhashmap

WeakHashMap類的putAll()方法 (WeakHashMap Class putAll() method)

  • putAll() method is available in java.util package.

    putAll()方法在java.util包中可用。

  • putAll() method is used to copy all of the associations or mappings from the given map and assign it to this map.

    putAll()方法用于從給定映射中復制所有關聯或映射,并將其分配給此映射。

  • putAll() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    putAll()方法是一種非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • putAll() method may throw an exception at the time of copy mappings.

    在復制映射時, putAll()方法可能會引發異常。

    NullPointerException: This exception may throw when the given parameter is null exists.

    NullPointerException :當給定參數為null時,可能引發此異常。

Syntax:

句法:

    public void putAll(Map map);

Parameter(s):

參數:

  • Map map – represents the mappings to be saved in this map.

    地圖地圖 –表示要保存在此地圖中的地圖。

Return value:

返回值:

The return type of the method is void, it returns nothing.

該方法的返回類型為void ,不返回任何內容。

Example:

例:

// Java program to demonstrate the example 
// of void putAll(Map map) method of WeakHashMap 
import java.util.*;
public class PutAllOfWeakHashMap {
public static void main(String[] args) {
// Instantiates a WeakHashMap object
Map < Integer, String > map = new WeakHashMap < Integer, String > ();
Map < Integer, String > put_map = new WeakHashMap < Integer, String > ();
// By using put() method is to add
// key-value pairs in a WeakHashMap
map.put(10, "C");
map.put(20, "C++");
map.put(50, "JAVA");
map.put(40, "PHP");
map.put(30, "SFDC");
// Display WeakHashMap
System.out.println("WeakHashMap: " + map);
// By using putAll() method is to
// copy all of the elements of the given
// object and paste it in an another object
put_map.putAll(map);
// Display put_map WeakHashMap
System.out.print("put_map.putAll(map): " + put_map);
}
}

Output

輸出量

WeakHashMap: {30=SFDC, 40=PHP, 10=C, 20=C++, 50=JAVA}
put_map.putAll(map): {30=SFDC, 10=C, 40=PHP, 20=C++, 50=JAVA}

翻譯自: https://www.includehelp.com/java/weakhashmap-putall-method-with-example.aspx

weakhashmap

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541437.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541437.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541437.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

c語言memcmp和java的_C語言memcmp()函數:比較m字節長的兩個字符串s1和s2

函數名&#xff1a;memcmp頭文件&#xff1a;函數原型&#xff1a; void* memcmp(void *s1,void *s2,unsigned m);功能&#xff1a;比較m字節長的兩個字符串s1和s2參數&#xff1a; s1 和 s2 為要比較的字符串unsigned m 為要比較的前m個字節返回值&#xff1a;s1s1s2 返回等…

[下載地址] Subclipse 1.10.9(SVN) _附說明

http://pan.baidu.com/s/1bp6EFHt轉載于:https://www.cnblogs.com/gscq073240/articles/6814429.html

hbase 偽分布安裝 java_HBase基礎和偽分布式安裝配置

一、HBase(NoSQL)的數據模型1.1 表(table)&#xff0c;是存儲管理數據的。1.2 行鍵(row key)&#xff0c;類似于MySQL中的主鍵&#xff0c;行鍵是HBase表天然自帶的&#xff0c;創建表時不需要指定1.3 列族(column family)&#xff0c;列的集合。一張表中有多個行健&#xff0c…

java treemap_Java TreeMap firstEntry()方法及示例

java treemapTreeMap類的firstEntry()方法 (TreeMap Class firstEntry() method) firstEntry() method is available in java.util package. firstEntry()方法在java.util包中可用。 firstEntry() method is used to retrieve the key-value pairs linked with the lowest valu…

linux常用網絡命令ping和arping

linux常用網絡命令ping和arping ping 向目標主機發送icmp請求包 常用來測試當前主機與目標主機網絡連接狀況 常見選項 -c 設置發包的個數 -s 設置發的包的塊大小&#xff0c;最大不超過65507 -W 設置接收回應超時時間 -i …

java printwriter實例_PrintWriter做過濾流+FileWriter案例分析

package com.mstf.ui;import java.io.*;public class TestWriter{public static void main(String args[]){//PrintWriter做過濾流FileWriter//doFilter1();//2、PrintWriter做過濾流OutputStreamWriter//doFilter2();//3、PrintWriter可以作為節點流//doNode();//4、PrintWrit…

treemap比較器_Java TreeMap比較器()方法與示例

treemap比較器TreeMap類的compare()方法 (TreeMap Class comparator() method) comparator() method is available in java.util package. 比較器()方法在java.util包中可用。 comparator() method is used to return the key element in this TreeMap based on the Comparator…

洛谷P1204 [USACO1.2]擠牛奶Milking Cows 前綴和

這題數據比較水 暴搜都能夠過去 1 #include <cstdio>2 #include <cmath>3 #include <cstdlib>4 #include <algorithm>5 #include <string>6 #include <iostream>7 #include <iomanip>8 #include <cstring>9 using namespace s…

java script創建對象_JavaScript七種非常經典的創建對象方式

JavaScript創建對象的方式有很多&#xff0c;通過Object構造函數或對象字面量的方式也可以創建單個對象&#xff0c;顯然這兩種方式會產生大量的重復代碼&#xff0c;并不適合量產。接下來介紹七種非常經典的創建對象的方式&#xff0c;他們也各有優缺點。一、工廠模式可以無數…

java 方法 示例_Java掃描儀具有示例的NextNextInt()方法

java 方法 示例掃描器類的hasNextInt()方法 (Scanner Class hasNextInt() method) Syntax: 句法&#xff1a; public boolean hasNextInt();public boolean hasNextInt(int rad);hasNextInt() method is available in java.util package. hasNextInt()方法在java.util包中可用…

axis2開發webservice之編寫Axis2模塊(Module)

axis2中的模塊化開發。能夠讓開發者自由的加入自己所需的模塊。提高開發效率&#xff0c;減少開發的難度。 Axis2能夠通過模塊&#xff08;Module&#xff09;進行擴展。Axis2模塊至少須要有兩個類&#xff0c;這兩個類分別實現了Module和Handler接口。開發和使用一個Axis2模塊…

java 看書瀏覽器官_JAVA讀取文件流,設置瀏覽器下載或直接預覽操作

最近項目需要在瀏覽器中通過url預覽圖片。但發現瀏覽器始終默認下載&#xff0c;而不是預覽。研究了一下&#xff0c;發現了問題&#xff1a;// 設置response的header&#xff0c;注意這句&#xff0c;如果開啟&#xff0c;默認瀏覽器會進行下載操作&#xff0c;如果注釋掉&…

Java PriorityQueue poll()方法與示例

PriorityQueue類poll()方法 (PriorityQueue Class poll() method) poll() method is available in java.util package. poll()方法在java.util包中可用。 poll() method is used to return the first element with removing an element from this PriorityQueue. poll()方法用于…

scrapy抓取淘寶女郎

scrapy抓取淘寶女郎 準備工作 首先在淘寶女郎的首頁這里查看&#xff0c;當然想要爬取更多的話&#xff0c;當然這里要查看翻頁的url,不過這操蛋的地方就是這里的翻頁是使用javascript加載的&#xff0c;這個就有點尷尬了&#xff0c;找了好久沒有找到&#xff0c;這里如果有朋…

map在Java集合_java集合之Map

MapMap用于保存具有映射關系的數據。Map中key不允許重復&#xff0c;value可以重復&#xff0c;key和value之間存在單向一對一關系HashMap和Hashtable區別1 Hashtable線程安全、HashMap線程不安全&#xff0c;所以HashMap性能高一點2 Hashtable不允許用null做key和value&#x…

Java OutputStream close()方法與示例

OutputStream類close()方法 (OutputStream Class close() method) close() method is available in java.io package. close()方法在java.io包中可用。 close() method is used to close this OutputStream stream and free all system resources linked with this stream and …

怎樣在fastboot 里面加入新的命令

fastboot 是android 默認的一種debug 方法。它的優點是在進入linux kernel 之前就可以操作。默認fastboot 支持的命令&#xff1a; usage: fastboot [ <option> ] <command>commands: update <filename> reflash device …

java編寫字符串連接程序注釋_Java 注解自動化處理對應關系實現注釋代碼化

public class EsQuery { private static int DEFAULT_SIZE 100; private final Map termFilter;private final Map rangeFilter;private final Map matchFilter;private int size;private String orderBy null;private String order null; // query 查詢語法, 是否需要 filtere…

getlanguage_Java語言環境getLanguage()方法與示例

getlanguage區域設置類getLanguage()方法 (Locale Class getLanguage() method) getLanguage() method is available in java.util package. getLanguage()方法在java.util包中可用。 getLanguage() method is used to retrieve this Locale language code and the language co…

[轉]Anaconda

安裝 Anaconda Anaconda 可用于 Windows、Mac OS X 和 Linux。可以在 https://www.continuum.io/down... 上找到安裝程序和安裝說明。 如果計算機上已經安裝了 Python&#xff0c;這不會有任何影響。實際上&#xff0c;腳本和程序使用的默認 Python 是 Anaconda 附帶的 Python。…