Pages

Tuesday, July 17, 2012

Java associative array

Today I wanted to use an associative array in java and came to know that java does not have associative aarays. how ever there is a similar data structure you can use instead of an associative array. That is a hash map.

Map<String, Object> map = new HashMap<>(String, Object);

to put objects in the map,

map.put("key","value");

to retrieve, you can use the key as below.

map.get("key");

No comments:

Post a Comment