Thanks for your clear response! The question to ask next is... why, if it
was a String in the hashtable do you need to do a "class cast"? By putting
and pulling the data into and outof the Hashtable does it somehow alter it?
In the code, which tries to pull it out of the Hashtable, it is being assigned
to a String variable so why do you need to cast it?

Thanks again,


"Paul Clapham" <> wrote:
>Yes, that's exactly what it's saying. The Java name for this is "class
>casting", and there is a bunch of rules for how it works. You can't just
>cast any class to any other class. So the programmer who wrote this code
>would have known that the objects in the hashtable were strings. Since

>hashtable and enumeration are generic and widely usable, they can only deal
>with Objects. And since all classes descend from Object, any object can

>cast into an Object variable.
>So the phrase "(String)buildingZone.get(buildingKey)" means: "Get the
>Object from the Hashtable buildingZone that belongs to the key buildingKey.
>And I know it was a String when I put it there, so cast it into a String
>But if it wasn't a String but some other class of Object, say a File or

>Integer, this will fail and a ClassCastException will be thrown at the
>Mark <> wrote in message
>> Here is the syntax in question:
>> for (int startYear=initYear; startYear<initYear+3; startYear++) {
>> for (Enumeration e=buildingZone.keys(); e.hasMoreElements(); ) {
>> String buildingKey = (String)e.nextElement();
>> String zone = (String)buildingZone.get(buildingKey);
>> generateBuildingSummaryReport(startYear, buildingKey, zone);
>> }
>> }
>> I think I understand what hashtables are and that enumeration provides

>> way to loop through a hashtable (in this case buildingZone is a

>> nextElement() is the way enumeration goes through the keys located within
>> buildingZone. If I've got it pegged this far, then the question is, "Why
>> is (String) in front of e.nextElement() and why is (String) in front of

>> Is this saying that whatever e.nextElement() finds we want to make it

>> a string variable? I am confused as to what (String) is being used for

>> Thanks in advance for you help.