Paul:

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,

Mark

"Paul Clapham" <pclapham@core-mark.com> 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

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

be
>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
>variable."
>
>But if it wasn't a String but some other class of Object, say a File or

an
>Integer, this will fail and a ClassCastException will be thrown at the
>program.
>
>Mark <msorteberg@inspec.com> wrote in message news:394a37d2@news.devx.com...
>>
>> 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

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

>hashtable).
>> 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

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

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

>here.
>> Thanks in advance for you help.

>
>