This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
For the usage, we use Properties object in our applet-servelet communication. When the applet needs to get some information from the server, we send a HTTP Query, then server responsds a Properties Object (in serialized form) to the applet. In side the calling method, we deseriazlie the object and get the Properties (key/value pair). I haven't used Enumeration lately. I think if you look at the API docs, you will understand what is Properties and Enumeration.
The "Properties" class is an extension of the "Hashtable" class. As such it is used to store key/value pairs. Later you can look up a value based on the key. It has a further capability of being able to retrieve its contents from a file formatted as such:
Generally the application [web or fat client] will load the properties file values at start-up and then use the property values to control aspects of the application (database connectivity, mail server names, etc.). If the property values are changed, the new values can easily be saved back out to a file. Many applications use "Properties" instances to manage configuration. However there are other [newer] mechanisms for doing the same thing. You can use a "ResourceBundle" which does the same thing, but handles locale-specific encodings for you automatically. As for "Enumeration", that is the 'old' way of looping through a collection, such as a "Properties" instance. The 'new' way is to use an "Iterator" instance, but if you're simply looking at the values either one will work. You should check into the Sun Collections tutorial for additional details.
Joined: Jan 10, 2001
That's informative. What does a System.getProperties()give?
As Wayne Johnson mentions above, Enumeration is a legacy interface that has been superceded by Iterator. It is not currently deprecated, but its use is usually considered obsolete for new code. However, there is another type of enumeration to which you might be refering. The upcomming release of Java 2, v1.5 will be adding built-in support for enumerations, which are created using the new keyword enum. Both C and C++ support enum, but Java hasn't. With the release of 1.5, that will change. The enum in Java will bear surface similarity to the enum supported by C/C++, but will be both more powerful and safer to use. This is a feature that many Java programmers have been looking forward to.
For my latest books on Java, including my Java Programming Cookbook, see HerbSchildt.com