Java System clearProperty() Method
Example
Remove a system property:
public class Main {
public static void main(String[] args) {
System.setProperty("app.color", "blue");
String old = System.clearProperty("app.color");
System.out.println(old);
System.out.println(System.getProperty("app.color"));
}
}
Definition and Usage
The clearProperty() method removes a system property, so it no longer has a value.
Tip: Use the setProperty() method to set the value of a system property.
Syntax
public static String clearProperty(String key)
Parameter Values
| Parameter | Description |
|---|---|
| key | Required. The name of the system property to remove. |
Technical Details
| Returns: | A String with the old value of the property, or null if it did not have a value. |
|---|
Related Pages
❮ System Methods