Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.
Program
package com.candidjava;
/*
* @author : Mohan
* @description : The java.lang.System.getProperty(String key) method gets the system property indicated by the specified key.
*/
public class PropertiesGetProperty {
public static void main(String[] args) {
// prints the name of the system property
System.out.println(System.getProperty("user.dir"));
// prints the name of the Operating System
System.out.println(System.getProperty("os.name"));
// prints Java Runtime Version
System.out.println(System.getProperty("java.runtime.version"));
}
}
Output
D:\mohan\Javadoc
Windows 7
1.8.0_05-b13
Explanation
public String getProperty(String key)
Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.
Parameters:
key - the property key.
Returns:
the value in this property list with the specified key value.