Home » Java programming language

Java ResourceBundle containsKey() Method with Example

ResourceBundle Class containsKey() method: Here, we are going to learn about the containsKey() method of ResourceBundle Class with its syntax and example.
Submitted by Preeti Jain, on March 24, 2020

ResourceBundle Class containsKey() method

  • containsKey() method is available in java.util package.
  • 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() 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() method may throw an exception at the time of checking the existence of the given element.
    NullPointerException: This exception may throw when the given parameter is null exists.


    public boolean containsKey(String key_ele);


  • String key_ele – represents the key element of this 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.


// Java program to demonstrate the example 
// of boolean containsKey(String key_ele) method 
// of ResourceBundle

import 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);


rb.containsKey(IncludeHelp...): true


Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.