From e4d146365b967e12fc65ebf3d535f9dcedbf76c5 Mon Sep 17 00:00:00 2001 From: seahi Date: Sun, 1 Dec 2024 22:36:34 +0800 Subject: [PATCH] java.util.Properties --- src/chapter6/Example21.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/chapter6/Example21.java b/src/chapter6/Example21.java index dafc24b..524e3a6 100644 --- a/src/chapter6/Example21.java +++ b/src/chapter6/Example21.java @@ -1,4 +1,20 @@ package chapter6; +import java.util.Enumeration; +import java.util.Properties; + public class Example21 { + public static void main(String[] args) { + Properties p = new Properties(); + p.setProperty("Backgroudnd", "red"); + p.setProperty("Font-size", "14px"); + p.setProperty("Language", "Chinese"); + + Enumeration names = p.propertyNames(); + while (names.hasMoreElements()) { + String key = (String) names.nextElement(); + String value = p.getProperty(key); + System.out.println(key + "=" + value); + } + } }