Java ListResourceBundle getContents()方法與示例

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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/379946.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/379946.shtml
英文地址,請注明出處:http://en.pswp.cn/news/379946.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

DOM元素的所有子元素 .elements

.elements屬性用來獲取某個DOM元素的所有子元素,是個很有用的屬性,可用于用className來獲取指定元素等用途。 轉載于:https://www.cnblogs.com/cly84920/archive/2008/08/06/4427136.html

sys.stdin.read和raw_input函數

sys.stdin.read函數 例子: import sysreadsys.stdin.read() for i in range(len(read)):print i,read[i],-1運行,當執行到readsys.stdin.read()會阻塞,等待我們輸入 我們輸入: h e當輸入,ctrlD結束輸入&#xff0c…

Java ObjectOutputStream writeFields()方法與示例

ObjectOutputStream類writeFields()方法 (ObjectOutputStream Class writeFields() method) writeFields() method is available in java.io package. 在java.io包中提供了writeFields()方法 。 writeFields() method is used to write the buffered fields to the ObjectOutpu…

利用帶關聯子查詢Update語句更新數據

Update是T-sql中再簡單不過的語句了,update table set columnexpression [where condition],我們都會用到。但update的用法不僅于此,真正在開發的時候,靈活恰當地使用update可以達到事半功倍的效果。 假定有表Table1(…

SQL Server 2000數據庫移植到SQL Server 2008R2數據庫服務器中碰到的”3145錯誤”及解決辦法...

辛苦忙碌了一個星期終于安裝配置好了TFS服務器,給每個團隊成員分配了賬戶和郵箱。不過,老機器中的部分數據需要備份到新機器中,其中在移植一個使用DVBBS架設的論壇的時候,出了點問題,記錄如下,以備查找&…

web安全----XSS漏洞之基本原理

0x01 概述 XSS為跨站腳本攻擊,XSS攻擊針對的是用戶層面的攻擊!類型有反射型XSS、存儲型XSS、DOM型XSS,這里的DOM可以理解為頁面,或者是所有的標簽、內容之和 0x02 反射型XSS 反射型XSS攻擊流程為: 即: …

面向對象(匿名內部類與有名字內部類的比較)

A:匿名內部類 就是內部類的簡化寫法B:前提 這里的類可以是具體類也可以是抽象類C:格式 new 類名或者接口(){ //表示繼承這個類或實現這個接口重寫方法}D:本質是什么呢? 是一個繼承了該類或者實現了該接口的子類匿名對象E:案…

如何在Python中針對一個值檢查多個變量?

Given multiple variables and they are assigned some values, we have to test a value with these variables. 給定多個變量并為其分配了一些值,我們必須使用這些變量測試一個值。 Let, there are three variables a, b and c and we have to check whether one…

品析《桃花庵歌》

桃花庵歌 【明】唐寅(YIN) 桃花塢里桃花庵,桃花庵下桃花仙; 桃花仙人種桃樹,又摘桃花賣酒錢。 酒醒只在花前坐,酒醉還來花下眠; 半醒半醉日復日,花落花開年復年。 但愿老死花酒間&#xf…

面向對象(匿名內部類重寫多個方法調用)

①匿名內部類只針對重寫一個方法的時候使用; ②若有多個方法,通過匿名內部類進行調用的時候,需要一個一個進行調用,比較麻煩,所以不建議使用。 ③匿名內部類是無法向下轉型的,向下轉型需要子類的類名,這里面沒有子類…

c++ 取兩個鏈表的交集_使用C ++程序查找兩個鏈表的交集

c 取兩個鏈表的交集Problem statement: Write a C program to find the intersection of two single linked lists. 問題陳述:編寫一個C 程序來查找兩個單個鏈表的交集。 Example: 例: Let the first linked list be:6->5->2->9->NULLLet …

只在IE中顯示

只在IE中顯示div{display:none;display:block;_display:block}轉載于:https://www.cnblogs.com/lishenglyx/archive/2008/08/21/1273089.html

web安全---XSS漏洞之標簽使用2

所有標簽已經測試完并可以使用&#xff0c;測試環境&#xff1a;DVWA的反射型XSS&#xff0c;等級low 0x01 <script>標簽 <script>alert(2)</script> <script>alert(2)</script//0x02 <img>標簽 <img src"x" onerroralert(1)…

Java——多線程(鐵路售票系統案例)

問題&#xff1a;鐵路售票&#xff0c;一共100張&#xff0c;通過四個窗口賣完。 要求&#xff1a;分別用 繼承Thread類 和 實現Runnable接口 去實現 ①用繼承Thread類去實現 package com.yy.syn;public class Demo3_Ticket { /*** 鐵路售票&#xff0c;一共100張&#xff…

Java LocalDateTime類| 帶示例的getDayOfWeek()方法

LocalDateTime類getDayOfWeek()方法 (LocalDateTime Class getDayOfWeek() method) getDayOfWeek() method is available in java.time package. getDayOfWeek()方法在java.time包中可用。 getDayOfWeek() method is used to get the field value day-of-week that is an enum …

軟件測試方法大匯總

軟件測試方法大匯總 軟件測試方法種類繁多&#xff0c;記憶起來混亂&#xff0c; 如果把軟件測試方法進行分類, 就會清晰很多。 我參考一些書籍和網上的資料&#xff0c; 把常用的軟件測試方法列出來&#xff0c; 讓大家對軟件測試行業有個總體的看法。 從測試設計方法分類 測試…

web安全----xss工具使用3

XSSer 0x01 安裝 環境&#xff1a;kali、python3&#xff08;必須是python3&#xff0c;kali默認為python2&#xff09; 安裝步驟&#xff1a; git clone https://github.com/epsylon/xsser.git cd xsser sudo python3 setup.py install 使用命令&#xff1a; xsser -h查看…

Java——多線程(死鎖)

死鎖是指&#xff1a;兩個或兩個以上的進程在執行過程中&#xff0c;由于競爭資源或者由于彼此通信而造成的一種阻塞的現象&#xff0c;若無外力作用&#xff0c;它們都將無法推進下去。此時稱系統處于死鎖狀態或系統產生了死鎖&#xff0c;這些永遠在互相等待的進程稱為死鎖進…

c# 前導0_C#| 用前導零填充整數

c# 前導0To pad an integer number with leading zero, we can use String.Format() method which is library method of String class in C#. 要用前導零填充整數&#xff0c;我們可以使用String.Format()方法&#xff0c;該方法是C&#xff03;中String類的庫方法。 using S…

走到盡頭的技術-MVC

MVC技術是一種WebApplication設計技術&#xff0c;相比于傳統Web應用程序&#xff0c;MVC可以使程序結構更加清晰&#xff0c;他采用 Model&#xff0c;View&#xff0c;Controller 來管理和架構我們的Web資源&#xff0c;將不同的請求&#xff08;request&#xff09;導向不同…