Home » Java programming language

Java ListResourceBundle handleKeySet() Method with Example

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

ListResourceBundle Class handleKeySet() method

  • handleKeySet() method is available in java.util package.
  • handleKeySet() method is used to get a set of all the existing keys in this ListResourceBundle.
  • handleKeySet() 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.
  • handleKeySet() method does not throw an exception at the time of returning the key set.

Syntax:

    public Set handleKeySet();

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 ListResourceBundle.

Example:

// Java program to demonstrate the example 
// of Set handleKeySet()  method 
// of ListResourceBundle 

import java.util.*;

// Instantiates a class that extends
// ListResourceBundle 
class GetKeySet extends ListResourceBundle {
 // By using getContent() method is to
 // get the contents in the form of 
 // 2D objects

 protected Object[][] getContents() {
  return new Object[][] {
   {
    "10",
    "C"
   }, {
    "20",
    "C++"
   }, {
    "30",
    "JAVA"
   }, {
    "40",
    "SFDC"
   }, {
    "50",
    "PHP"
   }
  };
 }

 protected Set < String > handleKeySet() {
  return new LinkedHashSet < String > ();
 }
}

public class Main {
 public static void main(String[] args) {
  // Instantiates an object of
  // GetKeys
  GetKeySet get_ob = new GetKeySet();

  // By using handleGetObject() method is
  // reurn the object for the given key
  // element 20 "C++"

  System.out.print("get_ob.getString(20): ");
  System.out.println(get_ob.getString("20"));
 }
}

Output

get_ob.getString(20): C++





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





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


© https://www.includehelp.com some rights reserved.