ListResourceBundle类的getContents()方法 (ListResourceBundle Class getContents() method)

  • getContents() method is available in java.util package.

    getContents()方法在java.util包中可用。

  • getContents() method is used to get the contents into the form of an Object array (Object [][]) and every item is pairs of objects in an Object[][] where first indices represent the key element and the second indices represent the value element linked with the key in an object array.

    getContents()方法用于将内容转换为Object数组(Object [] [])的形式,每个项目都是Object [] []中的成对对象,其中第一个索引代表键元素,第二个索引代表与对象数组中的键链接的value元素。

  • getContents() 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.

    getContents()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • getContents() method does not throw an exception at the time of getting contents.

    getContents()方法在获取内容时不会引发异常。

Syntax:

句法:

    protected abstract Object[][] getContents();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is Object [] [], it returns 2D object array that contains two objects in the form of key-value pairs.

该方法的返回类型为Object [] [] ,它返回2D对象数组,该数组包含两个键值对形式的对象。

Example:

例:

// Java program to demonstrate the example
// of Object[][] getContents()  method of
// ListResourceBundle
import java.util.*;
// Instantiates a class that extends
// ListResourceBundle
class GetContents 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"
}
};
}
}
public class Main {public static void main(String[] args) {// Instantiates an object of
// GetContents
GetContents get_c = new GetContents();
// Display the value for the
// given key element
System.out.println("get_c.getString(40): " + get_c.getString("40"));
}
}

Output

输出量

get_c.getString(40): SFDC

翻译自: https://www.includehelp.com/java/listresourcebundle-getcontents-method-with-example.aspx

Java ListResourceBundle getContents()方法与示例相关推荐

  1. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  2. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  3. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  4. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  5. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  6. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  7. java exec waitfor,Java Process waitFor()方法与示例

    流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...

  8. java arraylist.add(),Java ArrayList add()方法与示例

    ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...

  9. java rollback用法,Java Connection rollBack()方法与示例

    回滚操作将撤消当前事务所做的所有更改,即,如果调用Connection接口的rollBack()方法,则所有修改都将还原到最后一次提交. 您还可以通过将所需的Savepoint对象作为参数传递给此方法 ...

最新文章

  1. 工作5年后才明白的道理:不起眼的技能中,藏着你的未来
  2. 深度隐式表达:为什么不用mesh,点云,体素等表示方法?
  3. Oracle学习笔记:oracle的编程接口
  4. Jeff Doyle
  5. CentOS中升级openssl与卸载重装以及提示:error while loading shared libraries: libssl.so.1.1: cannot open shared ob
  6. 01、python数据分析与机器学习实战——Python科学计算库-Numpy
  7. python中not加变量是_MyPython--基础篇--变量
  8. 【今晚7点半】:GVoice 千万在线语音传输的那些事
  9. python distplot 图_Python可视化23 |seaborn.distplot公司单变量分布图(直方图|核密度图),23seaborndistplot...
  10. Leetcode 48 Rotate Image
  11. php开发我的收藏,我的收藏列表 · 老猫带你玩转ThinkPHP5 API开发 · 看云
  12. 分水岭算法(Watershed Algorithm)
  13. redis与mysql性能对比、redis缓存穿透、缓存雪崩
  14. 越狱开发笔记(三)——非越狱App砸壳
  15. POP模式,提示密码错误的问题(密码是对的)
  16. “任期”已近20年,这个AI训练工具有点儿问题
  17. Android系统java/native crash和anr异常处理流程以及DroboxManagerService日志记录
  18. Arduino入门(一)
  19. org.gjt.mm.mysql.Driver与com.mysql.jdbc.Driver区别
  20. 汽车喷漆车间风淋室八大参数TENAISU

热门文章

  1. AngularJS快速入门指南15:API
  2. JSP页面中使用超链接进行传输参数(参数是一个本地磁盘链接)问题
  3. 【译】10个有趣的JSCSS库(2018.10)
  4. web前端学习之ruby标记和rt/rp标记
  5. Web工程师必备的43款可视化工具
  6. ubuntu系统下如何修改host
  7. c#语言基础编程-转义符
  8. 关于$.getJson
  9. Windows 7 / Vista 分区问题
  10. apache camel 相关配置_使用apache camel从表中选择数据-问答-阿里云开发者社区-阿里云...