Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Since Properties extends Hashtable, can I use the Hashtable methods to add elements to a Properties list?

0
Posted

Since Properties extends Hashtable, can I use the Hashtable methods to add elements to a Properties list?

0

Technically speaking you can. However, you have to make sure you only add key-value pairs where both are strings. If you add something other than a String, the listing, loading, and saving methods won’t work as expected. Like the Stack/Vector subclass relationship, Properties/Hashtable should be a has-a relationship, not an is-a/subclass relationship. 3.When I wrap a collection to be read-only or synchronized, why can’t I call any of the collection methods via reflection without getting an IllegalAccessException ? When you wrap a collection through the static methods of the Collections class, this creates an instance of a package-private (default access) class. Because you don’t have access to these classes, you can’t call their methods via reflection (though you can call their methods directly through the appropriate interface). 4.What is a weak reference and what are they used for ? Normally the Java garbage collector plays safe. It will only free up the memory used by an object when

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123