Is it possible to put hashmap within a hashmap?
My code is,
while (rs.next())
{
i++;
current_client_ id = rs.getInt(1);
if(i==1)
{
clientIdMap.put (rs.getInt(1), callCenterIdMap .put(rs.getInt( 2), rs.getString(3) ));
}
else if(current_clie nt_id != previous_client _id)
{
callCenterIdMap = new HashMap<Integer , String>();
clientIdMap.put (current_client _id, callCenterIdMap .put(rs.getInt( 2), rs.getString(3) ));
}
else if(current_clie nt_id == previous_client _id)
{
clientIdMap.put (current_client _id, callCenterIdMap .put(rs.getInt( 2), rs.getString(3) ));
}
previous_client _id = current_client_ id;
}
rs is a result set.
clientIdMap and callCenterIdMap are the two hashmaps.
but while getting the values it is throwing NullPointerExce ption.
My code is right or any err is there. Please, help me. its showing key data of clientIdMap but showing "values" as null.
My code is,
while (rs.next())
{
i++;
current_client_ id = rs.getInt(1);
if(i==1)
{
clientIdMap.put (rs.getInt(1), callCenterIdMap .put(rs.getInt( 2), rs.getString(3) ));
}
else if(current_clie nt_id != previous_client _id)
{
callCenterIdMap = new HashMap<Integer , String>();
clientIdMap.put (current_client _id, callCenterIdMap .put(rs.getInt( 2), rs.getString(3) ));
}
else if(current_clie nt_id == previous_client _id)
{
clientIdMap.put (current_client _id, callCenterIdMap .put(rs.getInt( 2), rs.getString(3) ));
}
previous_client _id = current_client_ id;
}
rs is a result set.
clientIdMap and callCenterIdMap are the two hashmaps.
but while getting the values it is throwing NullPointerExce ption.
My code is right or any err is there. Please, help me. its showing key data of clientIdMap but showing "values" as null.
Comment