A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/java/util/java_util_properties.htm below:

Java Properties Class

Java Properties Class Introduction

The Java Properties class is a class which represents a persistent set of properties. The Properties can be saved to a stream or loaded from a stream. Following are the important points about Properties −

Class declaration

Following is the declaration for java.util.Properties class −

public class Properties
   extends Hashtable<Object,Object>
Field

Following are the fields for java.util.Properties class −

protected Properties defaults − This is the property list that contains default values for any keys not found in this property list.

Class constructors Sr.No. Constructor & Description 1

Properties()

This constructs creates an empty property list with no default values.

2

Properties(int initialCapacity)

This constructs creates an empty property list with no default values, and with an initial size accommodating the specified number of elements without the need to dynamically resize.

3

Properties(Properties defaults)

This constructs creates an empty property list with the specified defaults.

Class methods Methods inherited

This class inherits methods from the following classes −

Getting an Enumeration of Properties Keys Example

The following example shows the usage of java.util.Properties.propertyNames() method.

package com.tutorialspoint;

import java.util.Enumeration;
import java.util.Properties;

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

      // add some properties
      prop.put("Height", "200");
      prop.put("Width", "15");

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

      // print the enumaration elements
      while(enumeration.hasMoreElements()) {
         System.out.println("" + enumeration.nextElement());  
      }
   }
}
Output

Let us compile and run the above program, this will produce the following result −

Width
Height

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4