Java ListResourceBundle handleKeySet()方法与示例
ListResourceBundle类handleKeySet()方法
handleKeySet()方法在java.util包中可用。
handleKeySet()方法用于获取此ListResourceBundle中所有现有键的集合。
handleKeySet()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
返回键集时,handleKeySet()方法不会引发异常。
语法:
public Set handleKeySet();
参数:
它不接受任何参数。
返回值:
该方法的返回类型为Set,它返回此ListResourceBundle中所有现有键的Set视图。
示例
//Java程序演示示例
//SethandleKeySet()方法
//ListResourceBundle-
import java.util.*;
//实例化扩展的类
//ListResourceBundle-
class GetKeySet extends ListResourceBundle {
//通过使用getContent()方法是
//的形式获取内容
//2D对象
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) {
//实例化一个对象
//GetKeys-
GetKeySet get_ob = new GetKeySet();
//通过使用handleGetObject()方法是
//遍历给定键的对象
//元素20“C++”"C++"
System.out.print("get_ob.getString(20): ");
System.out.println(get_ob.getString("20"));
}
}输出结果
get_ob.getString(20): C++
热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便