Java SE API
ResourceBundle.getString()
Retrieve the string associated with a resource key. Java SE API; example uses Java 21-compatible syntax.
Formal Syntax & Structure
java syntaxjava
String getString(String key)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | String | Message key |
Return Value
String
Retrieve the string associated with a resource key.
Working Example
Example Snippetjava
import java.math.*;import java.time.*;import java.time.format.*;import java.time.temporal.*;import java.text.*;import java.util.*;public class Main { public static void main(String[] args) throws Exception { ResourceBundle messages = new ListResourceBundle() { protected Object[][] getContents() { return new Object[][]{{"ready", "آماده"}}; } }; System.out.println(messages.getString("ready").equals("آماده")); String composed = "é", decomposed = "e\u0301"; System.out.println(composed.equals(decomposed)); System.out.println(Normalizer.normalize(decomposed,Normalizer.Form.NFC).equals(composed)); Collator c = Collator.getInstance(Locale.FRENCH); c.setStrength(Collator.PRIMARY); System.out.println(c.compare("e","é")==0); }}