Re: How to create array of hash table with correct types
- From: jonbbbb <jon.berg@xxxxxxxxx>
- Date: Thu, 3 Jul 2008 18:07:06 -0700 (PDT)
Create the array slots in one step, then initialise the slots in a
statement each.
Thanks for your reply. I am still not sure I get it.
Hashtable<String, NodeAddress>[] cache = new Hashtable;
cache[0] = new Hashtable<String, NodeAddress>();
cache[1] = new Hashtable<String, NodeAddress>();
cache[2] = new Hashtable<String, NodeAddress>();
This compiles with warnings since the type of the type of the
Hashtable array is not set correctly, "Uses unsafe operations...".
My experience with the type stuff in Java is a bit rusty. Sorry.
Replacing in the above code:
Hashtable<String, NodeAddress>[] cache = new Hashtable;
with:
Hashtable<String, NodeAddress>[] cache = new Hashtable<String,
NodeAddress>[3];
blows up with "generic array creation"
How can I do it properly?
Jon.
.
- Follow-Ups:
- Re: How to create array of hash table with correct types
- From: Roedy Green
- Re: How to create array of hash table with correct types
- From: Lew
- Re: How to create array of hash table with correct types
- From: Roedy Green
- Re: How to create array of hash table with correct types
- References:
- How to create array of hash table with correct types
- From: jonbbbb
- Re: How to create array of hash table with correct types
- From: Roedy Green
- How to create array of hash table with correct types
- Prev by Date: new Date(), System.currentTimeMillis() and system clock accuracy
- Next by Date: Re: new Date(), System.currentTimeMillis() and system clock accuracy
- Previous by thread: Re: How to create array of hash table with correct types
- Next by thread: Re: How to create array of hash table with correct types
- Index(es):