PropDemo.java Source code

Java tutorial

Introduction

Here is the source code for PropDemo.java

Source

import java.util.Properties;
import java.util.Set;

class PropDemo {
    public static void main(String args[]) {
        Properties capitals = new Properties();

        capitals.put("Illinois", "Springfield");
        capitals.put("Missouri", "Jefferson City");
        capitals.put("Washington", "Olympia");
        capitals.put("California", "Sacramento");
        capitals.put("Indiana", "Indianapolis");

        Set states = capitals.keySet();

        for (Object name : states)
            System.out.println(name + " / " + capitals.getProperty((String) name));

        String str = capitals.getProperty("Florida", "Not Found");
        System.out.println("The capital of Florida is " + str + ".");
    }
}