[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

How to put multiple items to a hashtable

I have  object that I need to pass down to service.  At my work they wont allow value objects and I was told to just create a hash map and pass it down.

So for example I have the following data
First Name                Last Name           Mi
Smuck                       Joe                      A
Boone                       Daniel                  C

Now I want to create a hashtable which puts the three related items for each two rows in a hashtable(hashmap)??? Saw the below example but not grasping for mulitple related items.

Hashtable ht = new Hashtable();

 ht.put("One", new Integer(1));    
ht.put("Two", new Integer(2));

Object obj = ht.get("One");    
System.out.println(obj);
0
TheVeee
Asked:
TheVeee
1 Solution
 
Sathish David Kumar NCommented:
add that item in list ...
put that list in to ur HashTable
0
 
Roger NeymanRetired Software Engineer, Author, TeacherCommented:
for that matter group you "multiple items" in any object then put that in the map. in this example I use String array:


Map<String,String[]> multiMap = new HashMap<String,String[]>();

multiMap.put("Names",new String[] { "Betty", "Hai", "Knut" } ) ;
multiMap.put("Numbers", new String[] { "Three", "Two", "Fourteen"} ) ;
0
 
zzynxSoftware engineerCommented:
>> I want to create a hashtable which puts the three related items for each two rows in a hashtable(hashmap)???
A map contains key-value pairs.
I understand that the value shoud be an object that contains the first, last and middel names.
But what should be the key?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now