Java Properties.propertyNames()

Syntax

Properties.propertyNames() has the following syntax.

public Enumeration <?> propertyNames()

Example

In the following code shows how to use Properties.propertyNames() method.


/*  ww w  .  j  ava  2s.com*/
import java.util.Enumeration;
import java.util.Properties;

public class Main {

  public static void main(String[] args) throws Exception {
    Properties prop = new Properties();

    prop.put("Chapter Count", "200");
    prop.put("Tutorial Count", "15");
    prop.put("tutorial", "java2s.com");

    // assign the property names in a enumaration
    Enumeration<?> enumeration = prop.propertyNames();

    // print the enumaration elements
    System.out.println(enumeration.nextElement());
    System.out.println(enumeration.nextElement());

  }
}

The code above generates the following result.