Java Hashtable containsValue()方法與示例

哈希表類containsValue()方法 (Hashtable Class containsValue() method)

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

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

  • containsValue() method is used to check whether this table Hashtable associated one or more keys to the given value element (val_ele).

    containsValue()方法用于檢查此表Hashtable是否將一個或多個鍵關聯到給定值元素(val_ele)。

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

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

  • containsValue() method may throw an exception at the time of checking the key elements associated with the given value element (val_ele).

    在檢查與給定值元素(val_ele)相關的關鍵元素時, containsValue()方法可能會引發異常。

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

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

Syntax:

句法:

    public boolean containsValue(Object val_ele);

Parameter(s):

參數:

  • Object val_ele – represents the value element (val_ele) is to be checked.

    對象val_ele –表示要檢查的值元素(val_ele)。

Return value:

返回值:

The return type of the method is boolean,

方法的返回類型為boolean 。

  • It returns true when at least one keys associated with the given value element (val_ele).

    當至少有一個與給定值元素(val_ele)相關聯的鍵時,它返回true

  • It returns false, when none keys associated with the given value element (val_ele).

    當沒有與給定值元素(val_ele)關聯的鍵時,它返回false

Example:

例:

// Java program to demonstrate the example 
// of boolean containsValue(Object val_ele) 
// method of Hashtable 
import java.util.*;
public class ContainsValueOfHashtable {
public static void main(String[] args) {
//Instantiate a hashtable object  
Hashtable ht = new Hashtable();
// By using put() method is to
// add the linked values in an Hashtable
ht.put(10, "C");
ht.put(20, "C++");
ht.put(30, "JAVA");
ht.put(40, "PHP");
ht.put(50, "SFDC");
// Display Hashtable
System.out.println("Hashtable: " + ht);
// By using containsValue() method is to
// check whether the given value element
// atleast holds one key element or not
// in this Hashtable
boolean status = ht.containsValue("JAVA");
// Display Status
System.out.println("ht.containsValue(JAVA): " + status);
}
}

Output

輸出量

Hashtable: {10=C, 20=C++, 30=JAVA, 40=PHP, 50=SFDC}
ht.containsValue(JAVA): true

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

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

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

相關文章

php session redis db,php session redis 配置

具體環境:一臺apachephp的服務器(yum安裝remi源及配置 httpd-2.2.15 php-5.4.45)一臺redis服務器(yum安裝remi源及配置 redis-3.2.6)保證apache服務器可以訪問redis服務器的6379端口具體步驟:1、在apachephp服務器上安裝redis擴展點擊(此處)折疊或打開yu…

sigprocmask, sigpending, sigsuspend的用法

sigset_t set sigemptyset(&set) :清空阻塞信號集合變量 sigfillset(&set) :添加所有的信號到阻塞集合變量里 sigaddset(&set,SIGINT):添加單一信號到阻塞信號集合變量 sigdelset(&set,SIGINT):從阻塞信號集合變量中刪除單一信號 void handler(int …

Java Calendar getDisplayName()方法與示例

日歷類的getDisplayName()方法 (Calendar Class getDisplayName() method) getDisplayName() method is available in java.util package. getDisplayName()方法在java.util包中可用。 getDisplayName() method is used to return string denotation of the given calendar fie…

matlab dir數,DIR - matlab函數

DIR List directory.DIR directory_name lists the files in a directory. Pathnames andwildcards may be used. For example, DIR *.m lists all the M-filesin the current directory.D DIR(‘directory_name‘) returns the results in an M-by-1structure with the field…

(四)其他的說明

2019獨角獸企業重金招聘Python工程師標準>>> 關于日志,主要是利用aop來實現的。cn.demoframe.test.frame.service.LogAspect,這里在方法前做了個切面setReqReachTime,設置了一個請求達到時間。接下來還有個切面,是在co…

Java LocalDate類| 帶示例的compareTo()方法

LocalDate類compareTo()方法 (LocalDate Class compareTo() method) compareTo() method is available in java.time package. compareTo()方法在java.time包中可用。 compareTo() method is used to compare this LocalDate object to the given object. compareTo()方法用于將…

vm中linux物理內存不足解決方案

為什么80%的碼農都做不了架構師?>>> 之前創建的一個center os,默認是8GB,經過一頓折磨,裝jdk,tomcat,redis,mycat,nginx,mysql,hadoop...終于,內存不足了,在使用docker build某鏡像的時候。迭代懵逼了&am…

matlab7.0 6.5,任何處理matlab6.5與7.0.1的兼容問題

mdl文件在6.5里面做的,但是到了7.0里面卻打不開,下面就是相關信息:Warning: Unable to load model file d:\MATLAB7\work\*.mdl. Run "bdclose all; set_param(0, CharacterEncoding, Enc)" where Enc is one of windows-1252, I…

Java BigInteger類| 帶有示例的減去()方法

BigInteger類減去()方法 (BigInteger Class subtract() method) subtract() method is available in java.math package. exclude()方法在java.math包中可用。 subtract() method is used to subtract the given value from the value of this BigInteger. exclude()方法用于從…

php刪除第一個字母,php – 正在上傳的文件將第一個字母切斷

我正在將網站從具有WS2003,IIS6,PHP 5.2的服務器遷移到具有WS2008,IIS7和PHP 5.3的服務器我有一個html表單,上傳文件到網站.if(isset($_POST["Upload"])){echo "";print_r($_POST);print_r($_FILES);echo "";}?>在舊服務器上工作得很好,但在…

.7z.001,.7z.002這樣的文件如何解壓

1 如圖所示,壓縮分卷沒有顯示關聯的軟件來打開,Winrar右擊也無法解壓 2 可以使用7-ZIP軟件打開該文件,然后選擇提取(相當于Winrar的解壓),然后選擇提取路徑,默認是同一個文件夾,點擊…

二進制 |_元二進制搜索| 單邊二元搜索

二進制 & |Meta Binary Search is a one-sided binary search where we work on the index using bit manipulation. We are to find the target index by using bit manipulation like the below example where the algorithm is explained. 元二進制搜索是一種單面二進制…

codeMirror配置

介紹 CodeMirror是一款在線的支持語法高亮的代碼編輯器。官網:http://codemirror.net/ 下載后,解壓開到的文件夾中,lib下是放的是核心庫和核心css,模式下放的是各種支持語言的語法定義,主題目錄下是支持的主題樣式。一…

應夢框架9.0框架_.Net框架能力問題和解答

應夢框架9.0框架This section contains Aptitude Questions and Answers on .Net Framework. 本節包含有關.Net Framework的能力問題和解答。 1) There are the following options are given below, what are parts of the .NET Framework? FCL (Framework Class Library)Web…

php中文網視頻放不了,【雜談】看php中文網視頻課程的正確姿勢!

看在線課程如何集中精力學習?ki4網為你分享看ki4網視頻課程的正確姿勢!不談理論給些實用建議,可以根據你的情況多嘗試,看看哪條對你有用!1、選一門自己有興趣而且教師講得好的課程。(點擊學習:ki4網視頻教程…

算法筆記_065:分治法求逆序對(Java)

目錄 1 問題描述 2 解決方案 2.1 蠻力法 2.2 分治法(歸并排序) 1 問題描述 給定一個隨機數數組,求取這個數組中的逆序對總個數。要求時間效率盡可能高。 那么,何為逆序對? 引用自百度百科: 設 A 為一個有 n…

c#copyto_String.CopyTo()方法以及C#中的示例

c#copytoC#String.CopyTo()方法 (C# String.CopyTo() Method) String.CopyTo() method is used to copy a specified number of characters from given indexes of the string to the specified position in a character array. String.CopyTo()方法用于將指定數量的…

怎么查看我的php版本,怎樣查看php版本

怎樣查看php版本方法一:命令行查詢如果已經配置好環境變量,直接在命令行中輸入php -v,將會顯示php的版本信息。如果沒有配置環境變量,直接在命令行中進入到php的安裝目錄后,再輸入命令php -v,如圖所示是我在…

c ++ 繼承_C ++繼承| 查找輸出程序| 套裝1

c 繼承Program 1: 程序1&#xff1a; #include <iostream>#include <string.h>using namespace std;class Person {char name[15];int age;public:void SetPerson(int age, char* name){this->age age;strcpy(this->name, name);}};class Student : publi…

xor在PHP是什么意思,?=‘在PHP中是什么意思?

萬千封印因為它不會增加任何價值echo&#xff0c;我認為您希望了解PHP中的確切含義&#xff1a;Array([0] > Array([0] > 368 // T_OPEN_TAG_WITH_ECHO[1] > [2] > 1)[1] > Array([0] > 309 // T_VARIABLE[1] > $a [2] > 1)[2] > ; // U…