new Properties(Properties prop) : Properties « java.util « Java by API






new Properties(Properties prop)

  
/*
 * Output:
 * 
a 1
A 2
c: 3
z: default

 *  
 */

import java.util.Properties;

public class MainClass {
    public static void main(String args[]) {
        Properties prop = new Properties();
        prop.put("a", "1");
        prop.put("b", "2");
        prop.put("c", "3");
        Properties book = new Properties(prop);
        book.put("A", "4");
        book.put("B", "5");
        
        System.out.println("a " + book.getProperty("a"));
        System.out.println("A " + book.getProperty("b"));
        System.out.println("c: " + book.getProperty("c"));

        System.out.println("z: " + book.getProperty("z", "default"));
    }
}


           
         
    
  








Related examples in the same category

1.new Properties()
2.Properties: getProperty(String key)
3.Properties: getProperty(String key, String defaultValue)
4.Properties: list(PrintStream out)
5.Properties: load(InputStream inStream)
6.Properties: loadFromXML(InputStream in)
7.Properties: keySet()
8.Properties: propertyNames()
9.Properties: setProperty(String key, String value)
10.Properties: store(OutputStream out, String comments)
11.Properties: storeToXML(OutputStream os, String comment)