new Vector();
Hashtable ht = new Hashtable();
ht.put("A", "Stuff A");
ht.put("B", "Stuff B");
stuff.add(0, ht);
return stuff.toArray();
}
Object[] hashArray = getStuff();
for (int idx=0; idx
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 17, 2
ailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Robert Nicholson
> Sent: Wednesday, May 17, 2000 11:19 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Offtopic: Quick Java programming question...
>
>
> What does this do?
>
>
r v)
{
Hashtable[] h = null;
if (v != null)
{
h = new Hashtable[v.size()];
v.copyInto(h);
}
return h;
}
}
- Original Message -
From: Scott Costa <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 17, 2000 12:15 PM
Subject: Offtopic: Quick Ja
Are you sure?
- Original Message -
From: "Danny Trieu" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 17, 2000 2:21 PM
Subject: Re: Offtopic: Quick Java programming question...
> no can't do that
>
> toArray() return O
> > - Original Message -
> > From: "Scott Costa" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, May 17, 2000 10:15 AM
> > Subject: Offtopic: Quick Java programming question...
> >
> > > I'm trying t
Oops. I actually wanted to type this:
--
And the following is even faster (by a hair):
Hashtable ret = new Hashtable[stuff.size()];
stuff.toArray(ret);
return ret;
because you avoid the evil typecheck.
===
To u
TECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, May 17, 2000 10:15 AM
> Subject: Offtopic: Quick Java programming question...
>
> > I'm trying to write a method which returns an array of Hashtables, and in
> > the method, I am assembling the data as a vector, a
t Costa" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, May 17, 2000 10:15 AM
> Subject: Offtopic: Quick Java programming question...
>
> > I'm trying to write a method which returns an array of Hashtables, and
in
> > the method, I am as
From: "Bip Thelin" <[EMAIL PROTECTED]>
> Try exchange "return (Hashtable[]) stuff.toArray()" with:
> "return (Hashtable[]) stuff.toArray(new Hashtable[0])" It should do the
trick.
This is more efficient:
return (Hashtable[]) stuff.toArray(new Hashtable[stuff.size()]);
because the data will be p
()];
stuff.copyInto(hashArray);
return hashArray;
Good luck,
Jason B.
>- Original Message -
>From: "Scott Costa" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Wednesday, May 17, 2000 10:15 AM
>Subject: Offtopic: Quick Java programming question...
>
it casts the objects into hashtable array ojects...
-Original Message-
From: Robert Nicholson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 17, 2000 2:19 PM
To: [EMAIL PROTECTED]
Subject: Re: Offtopic: Quick Java programming question...
What does this do?
return (HashTable
What does this do?
return (HashTable[])stuff.toArray(new HashTable[0]);
- Original Message -
From: "Scott Costa" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 17, 2000 10:15 AM
Subject: Offtopic: Quick Java programming question...
> I
> private Hashtable[] getStuff() {
> Vector stuff = new Vector();
> Hashtable ht = new Hashtable();
> ht.put("A", "Stuff A");
> ht.put("B", "Stuff B");
> stuff.add(0, ht);
> return (Hashtable[]) stuff.toArray();
> }
Try exchange "return (Hashtable[]) stuff.toArray()" with:
"return (Ha
I'm trying to write a method which returns an array of Hashtables, and in
the method, I am assembling the data as a vector, and trying to user
"toArray()" to return the data as an array.
Something like this:
private Hashtable[] getStuff() {
Vector stuff = new Vector();
Hashtable ht = new Hash
14 matches
Mail list logo