java - HashSet vs. ArrayList -


so have custom class class have set of custom class students. this:

public class class {     private set<student> students;      // other methods } 

now adding , removing many students set students , changing many of private fields of student in set of students.

question: data structure should use best implement this? since changing property of student objects in set student (thereby changing hashcodes) should use arraylist instead?

what data structure should use best implement this? since changing property of student objects in set student (thereby changing hashcodes) should use arraylist instead?

if hashcodes set elements liable change, should not using hashset. (if do, data structure break, , elements in set liable go missing.)

but doubt should using arraylist either, because if hashcode() sensitive changes object, equals(object) too. , means contains(...) , similar methods won't able find objects.

i think should using map type, , using "student identifier" key.

(you override hashcode , equals equality means 2 objects have same id. makes equals(object) useless other purposes.)


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -