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 带狗狗训练
4 听力训练狗狗
6 怎训练狗狗
7 腹肌训练狗狗
8 网球训练狗狗
9 记叙文训练狗狗
10 狗狗太凶怎么训练
11 核心力量训练狗狗
12 狗狗乱叫怎么训练
13 发音训练狗狗
14 怎么训练狗狗叼东西给主人
15 荆州训练狗狗
16 篮球训练狗狗
17 做训练狗狗
18 训练狗狗坐姿