jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes HashMap HashSet or ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "HashMap HashSet or ..." Watch "HashMap HashSet or ..." New topic

HashMap HashSet or ...

alan fisher

Joined: Sep 27, 2003
Posts: 5
import java.util.*;
public class PrintingContainers {
static Map mfill(Map m) {
m.put("dog", "Bosco");
m.put("dog", "Spot");
return m;
public static void main(String[] args) {
System.out.println(mfill(new HashMap()));
// output {dog=Spot}
From this program,can I deduce that HashMap can only hold the mapping from one key to one object?If it does,how can I hold a mapping from one key to some objects?
Jeremy Thornton
Ranch Hand

Joined: Feb 21, 2002
Posts: 91
Maps contain a key, value pair.
If you want to key multiple objects just make the value a Collection.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: HashMap HashSet or ...
jQuery in Action, 3rd edition