In some cases i suffered the operation at that time,
We can use the both HashMap or Model Class (POJO) as a ArrayList Generic Like ArrayList<HashMap<K,V>>() OR ArrayList<ModelName>()
.
Can you suggest me which is the better as a memory point of view and performances vise.
I know both are the better in it place, but i just want to know if i have option to take both alternative.... which will the better ?
e.g. Suppose i have 2 variable both are string in POJO class, and same both are for HashMap.
so we have the list objects Like..
final ArrayList<Abc> listAbc = new ArrayList<Abc>();
for(final int i=0;i<2;i++){
Abc modelAbc = new Abc();
abc.setName("name");
abc.setLastName("lastName");
listAbc.add(modelAbc);
}
in this case i have to take two object of ABC class,
And in HashMap with List object it will...
final ArrayList<HashMap<String,String>> listMap = new ArrayList<HashMap<String,String>>();
for(final int i=0;i<2;i++){
HashMap<String,String> hashAbc = new HashMap<String,String>();
hashAbc.put("NAME","firstName");
hashAbc.put("LASTNAME","lastName");
listMap.add(hashAbc);
}
in this case i have to use two object of HashMap.
Now tell me which will i have to use for better performance? Which is occupier of high memory ?