cancel
Showing results for 
Search instead for 
Did you mean: 

Add Map into another Map

Former Member
0 Kudos

how do i add Map into another Map...

could it be done ?

for instance...

Map("userid","mgm");

Map("pwd","Abu");

is a very normal Map...

yet i want something like this

Map(JCOMap,"table");

Map(JCOMap,"structure");

Map(JCOMap,"parameterlist");

JCOMap may contains

JCOMap.put("userid","abu");

JCOMap.put("pwd","Hassan");

PLS ADVICE. ..or other method will do

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

yzme,

Can't understand your question.

1. If you want to add all entries from one map into another then do something like this:


final Map first = new HashMap();
first.put("user", "someone");
first.put("password", "secret");

final Map second = new HashMap(first);
second.put("sid", "ERP");
second.put("sys", "00");

This way second will contain properties "user", "password", "sid" and "sys". First 2 properties are copied from map "first".

2. If you want to have nested maps then:


final Map logonData = new HashMap();
logonData.put("user", "someone");
logonData.put("password", "secret");

final Map sysData = new HashMap();
sysData.put("sid", "ERP");
sysData.put("sys", "00");

final Map allData = new HashMap();
allData.put("logon", logonData);
allData.put("sys", sysData);

Valery Silaev

SaM Solutions

http://www.sam-solutions.net