Zeljko Trogrlic wrote:
> >> But my question is still open: is it safe because they are not unique to
> >> element?
> >>
> >
> >They are still unique ever new element still gets a unique hashcodes, and all
> >strings are turned into StringElements getting a unique object hashcode at
> that
> >point.
>
> Where do you actually implement hashCode method?
>
> >> And isn't it easier and faster to simply wrap int with Integer rather than
> >> convert it to String?
> >
> >We do it this way so that we are dealing with a known. We know that all
> >keys are
> >strings and therefore can make certain assumptions. It's hard to do
> >comparisions
> >against an unknown.
>
> It's Integer, not unknown.
Ok so if I do.
addElement("mybold",new B());
It's not an integer anymore and I have to check instanceof so i can do a
comparison. The whole reason we use a hashtable instead of a vector is so that we
dont have to remember the order in which we inserted elements so we can access
anyelement that has been inserted as long as we know the name, I use
Integer.toString(Object.getHashCode()) more for convience so that I don't force
everyone to name their elements.
-stephan
--
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]