A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Sep 03, 2008
Sep 16, 2008 12:33:00
Hashtable ht = new Hashtable<String, String>();
shouldnt it give the error?if not then then whats the reason?
Joined: Oct 13, 2005
Sep 16, 2008 13:09:00
You are usually better using the
<K, V> class, but there is nothing wrong with the code you posted.
Also, it would be better to declare the reference as Map<
Change Hashmap to
[ September 16, 2008: Message edited by: Campbell Ritchie ]
Joined: Oct 27, 2005
Sep 16, 2008 14:17:00
It won't give you an error (since a Hashtable<String,String> still is a Hashtable), but later on you will most definitely get some warnings - either when trying to add something or when casting back to Hashtable<String,String>.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions
How To Answer Questions
I agree. Here's the link:
subject: ganeric type
Strings and Hashtables
Hashtable allowing null values
Best way to do generics?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015