Home Ask Login Register

Developers Planet

Your answer is one click away!

Rameshbabu February 2016

How to declare genericy key value pair array in java

Hello friends i am new to java collection, i need to create an array as follows,

Array( "key1":"value1", "key2":[ "key21":"value21", "key22":"value22" ], "key3":"value3" )

value's datatype's are specified dynamically. If example or tutorials available please share it. Thanks in advance.


chenchuk February 2016

Map is a key-value pair

    public static void main(String[] args) {
        Map<Integer, Object> map;
        map = new HashMap<Integer, Object>();
        map.put(1,"any object");
        map.put(2,"fits here");

Post Status

Asked in February 2016
Viewed 3,468 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life