File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes  Properties and enumeration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " Properties and enumeration" Watch " Properties and enumeration" New topic
Author

Properties and enumeration

divya madala
Ranch Hand

Joined: Jan 10, 2001
Posts: 61
Please explain what is Properties?
what is enumeration?
What cases they are used?
Thanks for your help!!!
Sreenivasa Majji
Ranch Hand

Joined: Jul 12, 2001
Posts: 224
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.


Sreenivasa Majji
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
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.
divya madala
Ranch Hand

Joined: Jan 10, 2001
Posts: 61
That's informative. What does a System.getProperties()give?
Herb Schildt
Author
Ranch Hand

Joined: Oct 01, 2003
Posts: 239
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Properties and enumeration