This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes ganeric type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ganeric type" Watch "ganeric type" New topic

ganeric type

geet kaur
Ranch Hand

Joined: Sep 03, 2008
Posts: 78

shouldnt it give the error?if not then then whats the reason?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37884
You are usually better using the HashMap<K, V> class, but there is nothing wrong with the code you posted.
Also, it would be better to declare the reference as Map<String, String>.

[edit]Change Hashmap to HashMap.[/edit]
[ September 16, 2008: Message edited by: Campbell Ritchie ]
Rob Spoor

Joined: Oct 27, 2005
Posts: 19649

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

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: ganeric type
Similar Threads
Hashtable allowing null values
Recursive Methods
Strings and Hashtables
Best way to do generics?
better way?