GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing www.tutorialspoint.com — Java ListResourceBundle Class
Selected Reading
Java ListResourceBundle ClassIntroductionThe Java ListResourceBundle class is an abstract subclass of ResourceBundle that manages resources for a locale in a convenient and easy to use list. Class declarationFollowing is the declaration for java.util.ListResourceBundle class − public abstract class ListResourceBundle extends ResourceBundle FieldFields inherited from class java.util.ResourceBundle. Class constructors
Class methods
Methods inheritedThis class inherits methods from the following classes −
Getting and iterating Keys of ListResourceBundle ExampleThe following example shows the usage of Java ListResourceBundle getKeys() method to iterate keys of the ListResourceBundle. We've created a ListResourceBundle object having contents an two dimensional array of String, Integer. Then few entries are added by overriding getContents() method and then an enumeration of keys is retrieved and iterated to print the keys. package com.tutorialspoint;
import java.util.Enumeration;
import java.util.ListResourceBundle;
// create a class that extends to ListResourceBundle
class MyResources extends ListResourceBundle {
// get contents must be implemented
protected Object[][] getContents() {
return new Object[][] {
{"1", 1},
{"2", 2},
{"3", 3}
};
}
}
public class ListResourceBundleDemo {
public static void main(String[] args) {
// create a new MyResources instance
MyResources mr = new MyResources();
// get the keys
Enumeration<String> enumeration = mr.getKeys();
// print the keys
while (enumeration.hasMoreElements()) {
System.out.println("" + enumeration.nextElement());
}
}
}
OutputLet us compile and run the above program, this will produce the following result. 1 2 3 Advertisements
| ||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |