Hi all
i read a csv file and store each line's data into a class MyData.
this class contains a variable of id - unique for object.
i want to store all my MyData object in a collection for later use.
if i want to access them in the fastest way, should i store my objects in a hashmap, and the key value would be their id?
like -
HashMap hashmap = new HashMap();
MyClass mc1 = new MyClass(1); //id =1
MyClass mc2 = new MyClass(4); //id =4
//i add the objects
hashmap.put(mc1.getID(),mc1);
hashmap,put(mc2.getID(),mc2);
//then when i want to get a certain object, where id is 4:
MyClass mc = hashmap.get(4);
should i use other collection? or is it fine that way?
Thanks!