I need to understand something for a homework at OOP course. The objective is to simulate a small bank application.And I am confused at this part : "Implement the class Bank using a predefined collection which uses a hashtable. The hashtable key will be generated based on the account main holder." So HashTable, HashSet and HashMap having are good to use. Yet, can I also use TreeMap or TreeSet? I founded that java.util.TreeMap works in the same way. They even have same method put , remove etc. To sum up , should I use only classes having "Hash" or can I use also the others like TreeMap?
Asked
Active
Viewed 25 times
0
-
There is quite a big difference between a set and a map. – Andy Turner May 03 '18 at 14:44
-
I know that . But am I restricted to use a certain collection? Or what kind of collection do you think I should use based on the problem statement – Tufisi Radu May 03 '18 at 14:46
-
Consider it a learning experience: try implementing it with one; then try changing the code to use the other, and see what the difference is. If you use `Map` or `Set` in your code everywhere except where you actually create instances (e.g. `Map
map = new HashMap<>()`), it is a simple matter of changing the `HashMap` to `TreeMap` in those places. – Andy Turner May 03 '18 at 15:03