本文共 1980 字,大约阅读时间需要 6 分钟。
containsKey() method is available in java.util package.
containsKey()方法在java.util包中可用。
containsKey() method is used to check whether the given key element (key_ele) exists or not exists in this ResourceBundle or its super bundles.
containsKey()方法用于检查此ResourceBundle或其超级捆绑包中是否存在给定的关键元素(key_ele)。
containsKey() 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.
containsKey()方法是一个非静态方法,只能由类对象访问,如果尝试使用类名访问该方法,则会收到错误消息。
containsKey() method may throw an exception at the time of checking the existence of the given element.
在检查给定元素是否存在时, containsKey()方法可能会引发异常。
NullPointerException: This exception may throw when the given parameter is null exists.
NullPointerException :当给定参数为null时,可能引发此异常。
Syntax:
句法:
public boolean containsKey(String key_ele);
Parameter(s):
参数:
String key_ele – represents the key element of this ResourceBundle.
字符串key_ele –表示此ResourceBundle的关键元素。
Return value:
返回值:
The return type of this method is boolean, it returns true when the given key element exists in this ResourceBundle or its super bundle otherwise it returns false.
此方法的返回类型为boolean ,当给定的key元素存在于此ResourceBundle或其超级捆绑包中时,它返回true ,否则返回false 。
Example:
例:
// Java program to demonstrate the example // of boolean containsKey(String key_ele) method // of ResourceBundleimport java.util.*;public class ContainsKeyOfResourceBundle { public static void main(String[] args) { // Instantiates ResourceBundle with // some locale ResourceBundle rb = ResourceBundle.getBundle("IncludeHelp...", Locale.FRANCE); // By using containsKey() method isto // check whether the given key exists or // not in this ResourceBundle boolean status = rb.containsKey("IncludeHelp..."); // Display status System.out.println("rb.containsKey(IncludeHelp...): " + status); }}
Output
输出量
rb.containsKey(IncludeHelp...): true
翻译自:
转载地址:http://nwvzd.baihongyu.com/