Sobes.tech
Junior — Middle

Kas saaksid loetleda Properties tüüpi objektide peamised omadused Java's?

sobes.tech AI

Vastus AI-lt

The Properties objects in Java represent a specialized class for storing key-value pairs, where both the key and the value are strings. Main features:

  • Inherit from Hashtable<Object,Object>, but are typically used with String.
  • Commonly used for storing configuration parameters.
  • Allow loading and saving data in .properties format via load(InputStream) and store(OutputStream, String) methods.
  • Support specifying default values through the constructor.
  • Do not guarantee the order of elements.

Usage example:

Properties props = new Properties();
props.setProperty("username", "admin");
props.setProperty("password", "12345");

String user = props.getProperty("username");