Maybe that's simple question. But, I wonder to know why we can't populate array or collection with null values? Please look such simple example:
public static void main(String[] args) {
Map<String, Object> map = new HashMap<>();
map.put("first",null);
map.put("first1",new BigDecimal(1.5));
map.put("first2",new BigDecimal(2.5));
map.put("first3",new BigDecimal(3.5));
String[]array1 = new String[map.values().size()];
Object[]array2 = new Object[map.values().size()];
int counter = 0;
for(Map.Entry<String,Object> entry: map.entrySet()){
String header = entry.getKey();
Object value = entry.getValue();
array1[counter] = header;
array2[counter] = value;
counter++;
}
}
I would be glad to listen your purposes.
Maphas asizemethod so no need formap.values().size()just usemap.size().