Hi,
I want to Map a single key to array of values. Is that possible?

Recommended Answers

All 5 Replies

any1 thr..pls help:(

So, you want to do something like:

Map<String, Object[]> objectMap = new TreeMap<String, Object[]>();
Object[] values = new String[] {"A", "B", "C"};
objectMap.put("First3Letters", values);

Is that right? Yes, you can do that.

Exactly, but, I have read that: "each key can map to at most one value"

That means that each key can map to one entry in the map. The map doesn't care what's in the entry (or "value" as it is called). All it knows is that there is an object there (an array is considered an object).

Does that make sense?

Got it...Thank u:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.