Java ListResourceBundle() Constructor

Syntax

ListResourceBundle() constructor from ListResourceBundle has the following syntax.

public ListResourceBundle()

Example

In the following code shows how to use ListResourceBundle.ListResourceBundle() constructor.


import java.util.HashSet;
import java.util.ListResourceBundle;
import java.util.Set;
//  w  ww . j  av  a 2s. c o m
class MyResources extends ListResourceBundle {
  public MyResources(){
    super();
  }
  protected Object[][] getContents() {
    return new Object[][] { 
        { "hello", "from java2s.com" },
        { "client", "HTML" }, 
        { "server", "PHP" } };
  }

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

  }
}

public class Main {
  public static void main(String[] args) {
    MyResources mr = new MyResources();

    System.out.println(mr.getString("hello"));
  }
}

The code above generates the following result.