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.mzph.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…