Properties: keySet() : Properties « java.util « Java by API






Properties: keySet()

  
/**
 *Output:
 The value of K2 is V2.
The value of K1 is V1.
 */

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

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

    capitals.put("K1", "V1");
    capitals.put("K2", "V2");

    Set states = capitals.keySet();

    for (Object name : states)
      System.out.println("The value of " + name + " is "
          + capitals.getProperty((String) name) + ".");
  }
}

           
         
    
  








Related examples in the same category

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