How To Delete Property From java.util.Properties

By Angsuman Chakraborty, Gaea News Network
Saturday, August 23, 2008

This isn’t a trick question. For a long time you couldn’t delete a property from java.util.Properties class. In the recent versions too Java doesn’t reveal that it has added the functionality. However as java.util.Properties now extends Hashtable, you can delete a property by:

Properties.remove(key);

So effectively Properties is a persistent Hashtable which is limited to String key and value pairs only.

Discussion

Herbert Helmstreit
May 1, 2009: 7:21 am

java.lang.Object
|
+—-java.util.Dictionary
|
+—-java.util.Hashtable
|
+—-java.util.Properties

This was the inheritance in Java 1.1

August 24, 2008: 12:23 am

I don’t remember using it earlier but I definitely don’t remember the exact version. I think it should be around 1.5 or later.

August 24, 2008: 12:07 am

Couldn’t find it in the docs.


Laird Nelson
August 23, 2008: 12:41 pm

Hasn’t Properties extended Hashtable since JDK 1.1?

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :