I am trying to write a generic function that return the last added value in a hashmap. i created the same method for the ArrayList but i do not know how to do it for the HashMap
public <T><T> T lastAddedObj(HashMap<Integer, T> list) {
// TODO Auto-generated method stub
if (list != null) {
if (!list.isEmpty()) {
return list.get(( list.size() - 1) );
} else {
Log.E(TAG, "lastAddedObj", "the generic object list received is empty!!");
return null;
}
} else {
Log.E(TAG, "lastAddedObj", "the generic object list received is null!!");
return null;
}
}