Java IdentityHashMap keySet()方法及示例

IdentityHashMap類keySet()方法 (IdentityHashMap Class keySet() method)

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

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

  • keySet() method is used to get a set of all the existing keys in this IdenityHashMap to be viewed in a Set.

    keySet()方法用于獲取此IdenityHashMap中所有現有鍵的集合,以在Set中進行查看。

  • keySet() 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.

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

  • keySet() method does not throw an exception at the time of returning the key set.

    返回鍵集時, keySet()方法不會引發異常。

Syntax:

句法:

    public Set keySet();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of the method is Set, it returns Set view of all the existing keys in this IdenityHashMap.

方法的返回類型為Set ,它返回此IdenityHashMap中所有現有鍵的Set視圖。

Example:

例:

// Java program to demonstrate the example 
// of Set keySet() method of IdentityHashMap 
import java.util.*;
public class KeySetOfIdentityHashMap {
public static void main(String[] args) {
// Instantiates a IdentityHashMap object
Map < Integer, String > map = new IdentityHashMap < Integer, String > ();
// By using put() method is to add
// key-value pairs in a IdentityHashMap
map.put(10, "C");
map.put(20, "C++");
map.put(50, "JAVA");
map.put(40, "PHP");
map.put(30, "SFDC");
// Display IdentityHashMap
System.out.println("IdentityHashMap: " + map);
// By using keySet() method is to
// return the set of of keys exists
// in this IdentityHashMap to be viewed in 
// a Set
Set s = map.keySet();
// Display status
System.out.print("map.keySet(): ");
System.out.println(s);
}
}

Output

輸出量

IdentityHashMap: {20=C++, 40=PHP, 50=JAVA, 30=SFDC, 10=C}
map.keySet(): [20, 40, 50, 30, 10]

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

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

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

相關文章

C#省市二級聯動(王者榮耀挑選英雄為例)

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;namespace beyond_聯動_ {public partial clas…

二叉排序樹(Binary Sort Tree) 又稱為二叉查找樹(Binary Search Tree) - (代碼、分析)

目錄&#xff1a;代碼&#xff1a;分析&#xff1a;代碼&#xff1a; BSTree.h #ifndef _BSTREE_H_ #define _BSTREE_H_typedef void BSTree;//定義二叉樹類型 typedef void BSKey;//定義節點的鍵值類型&#xff08;用于節點排序&#xff09;typedef struct _tag_BSTreeNode …

springboot tomcat默認線程數_記一次JAVA線程池的錯誤用法

最近項目一個項目要結項了&#xff0c;但客戶要求 TPS 能達到上千&#xff0c;而用我寫的代碼再怎么弄成只能達到 30 的 TPS&#xff0c;然后我又將代碼中能緩存的都緩存了&#xff0c;能拆分的也都拆分了&#xff0c;拆分時用的線程池來實現的&#xff1b;其實現的代碼主要為…

引以為鑒-ARM開發板連線注意事項

前些日子把實驗室的三臺機子放到一個工位上&#xff0c;非常擁擠&#xff0c;做實驗也很不方便。因此&#xff0c;想把ARM開發板的環境重新搭建到自己的電腦上。說完就做&#xff0c;上午就開始忙活起來。把開發板上的USB線、串口線、JTAT接口、還有電源線一一插好。接著就開始…

CString 類型和引用

怎么理解CString & 類型&#xff1f;在函數參數表中&#xff0c;列了一項是此類型&#xff0c;據說是引用。可以給個具體方法&#xff0c;示例么&#xff1f; 由于子程序調用是棧傳遞參數&#xff0c;因此對參數的修改不會改變調用者傳入的參數的值。如果要改變調用者的參數…

Java IdentityHashMap putAll()方法與示例

IdentityHashMap類putAll()方法 (IdentityHashMap Class putAll() method) putAll() method is available in java.util package. putAll()方法在java.util包中可用。 putAll() method is used to copy all of the entry (key-value pairs) that exists from the given map (m)…

Python---實驗八

1&#xff0c;現在有一份‘邀請函.txt’的空白文件&#xff0c;請在同級目錄下編寫一段代碼&#xff0c;寫入內容‘誠摯邀請您來參加本次宴會’。 with open(fG:\study\Python\邀請函.txt,modew,encodingutf-8) as y:y.write(誠摯邀請您來參加本次宴會)效果圖如下&#xff1a;…

哈希表 - (代碼、分析 )

目錄&#xff1a;代碼&#xff1a;分析&#xff1a;代碼&#xff1a; BSTree.h BSTree.c 二叉排序樹(Binary Sort Tree) 又稱為二叉查找樹(Binary Search Tree) Hash.h #ifndef _HASH_H_ #define _HASH_H_typedef void Hash;//定義哈希表類型 typedef void HashKey;//定義哈…

scala spark 數據對比_IT大牛耗時三個月總結出大數據領域學習路線,網友評論:炸鍋了...

大數據不是某個專業或一門編程語言&#xff0c;實際上它是一系列技術的組合運用。有人通過下方的等式給出了大數據的定義。大數據 編程技巧 數據結構和算法 分析能力 數據庫技能 數學 機器學習 NLP OS 密碼學 并行編程雖然這個等式看起來很長&#xff0c;需要學習的東…

Java IdentityHashMap equals()方法與示例

IdentityHashMap類equals()方法 (IdentityHashMap Class equals() method) equals() method is available in java.util package. equals()方法在java.util包中可用。 equals() method is used to check whether this IdentityHashMap object and the given object (ob) are eq…

jQuery中關于Ajax的詳解

本文介紹如何使用jquery實現Ajax功能. 用于發送Ajax請求的相關函數如load, get, getJSON和post這些漸變Ajax方法, 對于核心的ajax 方法沒有過多介紹, 主要是通過配置復雜的參數實現完全控制Ajax請求。 Ajax讓用戶頁面豐富起來, 增強用戶體驗. Ajax是所有Web開發的必修課. 雖然A…

Python---實驗九作業

1&#xff0c;使用tkinter實現計算器程序。實現效果如下&#xff1a; from tkinter import * from tkinter.ttk import *def frame(master):"""將共同的屬性作為默認值, 以簡化Frame創建過程"""w Frame(master)w.pack(sideTOP, expandYES, fill…

分析FLV文件分析和解析器的開源代碼

分析一下GitHub上一份FLV文件分析和解析器的開源代碼 GitHub源碼地址&#xff1a;功能強大的 FLV 文件分析和解析器 &#xff1a;可以將flv文件的視頻tag中的h264類型數據和音頻tag中的aac類型數據導出 &#xff08;只限h264和aac&#xff09; (這個代碼不太適合用于大文件的分…

用pv操作描述如下前驅圖_LinkedList實現分析(二)——常用操作

上一篇文章LinkedList實現分析(一)——LinkedList初探與對象創建介紹了LinkedList中的一些重要屬性和構造方法&#xff0c;下面我們將詳細介紹一下LinkedList提高的常用方法的實現原理元素添加###add(E e)方法往LinkedList添加元素&#xff0c;LinkedList提供了多重方式&#x…

C++多重繼承與虛基類及與.NET的比較

多重繼承前面我們介紹的派生類只有一個基類&#xff0c;稱為單基派生或單一繼承。在實際運用中&#xff0c;我們經常需要派生類同時具有多個基類&#xff0c;這種方法稱為多基派生或多重繼承。2.1 多重繼承的聲明&#xff1a;在 C 中&#xff0c;聲明具有兩個以上基類的派生類與…

Javascript的IE和Firefox兼容性匯編

window.event現有問題&#xff1a;使用 window.event 無法在 FF 上運行解決方法&#xff1a;FF 的 event 只能在事件發生的現場使用&#xff0c;此問題暫無法解決。可以這樣變通&#xff1a;原代碼(可在IE中運行)&#xff1a;<input type"button" name"someB…

Java Double類compareTo()方法與示例

雙類compareTo()方法 (Double class compareTo() method) compareTo() method is available in java.lang package. compareTo()方法在java.lang包中可用。 compareTo() method is used to check equality or inequality for this Double-object against the given Double-obje…

平院實訓門禁系統導入

這是我的配置&#xff08;如果是Win10最好每一步都管理員身份運行&#xff09; win7 SQLServer2008 VS2012 切記&#xff1a;注意&#xff1a;當你SQLserver創建數據庫和VS連接數據庫的時候得用同一種方式&#xff0c;要么都用window&#xff08;主機名&#xff09;&#xff0…

ffmpeg 解碼音頻(aac、mp3)輸出pcm文件

ffmpeg 解碼音頻&#xff08;aac、mp3&#xff09;輸出pcm文件 播放pcm可以參考&#xff1a; ffplay -ar 48000 -ac 2 -f f32le out.pcm main.c #include <stdio.h> #include <stdlib.h> #include <string.h>#include <libavutil/frame.h> #include …

Jquery getJSON()

getJSON與aspx 準備工作 Customer類 public class Customer{public int Unid { get; set; }public string CustomerName { get; set; }public string Memo { get; set; }public string Other { get; set; }}&#xff08;一&#xff09;ashx Customer customer new Customer { …