Property Maps Core Java

A property map is a map structure of a very special type. It has three particular characteristics:

  • The keys and values are strings.
  • The table can be saved to a file and loaded from a file.
  • A secondary table for defaults is used.

The Java platform class that implements a property map is called Properties. Property maps are commonly used in specifying configuration options for programs

java.util.Properties 1.0

  • Properties()
    creates an empty property map.
  • Properties(Properties defaults)
    creates an empty property map with a set of defaults.
  • String getProperty(String key)
    gets a property association; returns the string associated with the key, or the string associated with the key in the default table if it wasn’t present in the map.
  • String getProperty(String key, String defaultValue)
    gets a property with a default value if the key is not found; returns the string associated with the key, or the default string if it wasn’t present in the map.
  • void load(InputStream in)
    loads a property map from an InputStream.
  • void store(OutputStream out, String commentString)
    stores a property map to an OutputStream.

Stacks

Since version 1.0, the standard library had a Stack class with the familiar push and pop methods. However, the Stack class extends the Vector class, which is not satisfactory from a theoretical perspective—you can apply such un-stack-like operations as insert and remove to insert and remove values anywhere, not just at the top of the stack.

java.util.Stack<E> 1.0

  • E push(E item)
    pushes item onto the stack and returns item.
  • E pop()
    pops and returns the top item of the stack. Don’t call this method if the stack is empty.
  • E peek()
    returns the top of the stack without popping it. Don’t call this method if the stack is empty.

Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Core Java Topics