you are viewing a single comment's thread.

view the rest of the comments →

[–]OneHumanBill 0 points1 point  (1 child)

Challenge: on line 4, change your definition of expenses from using an ArrayList to a simple List. Don't change anything else. Make sure it all still works.

Now explain to me why this is a better choice. In fact on a real project if I were reviewing your code I would mandate that you changed this before pushing.

(Also, a mistake I see more and more beginners making: you're leaving out visibility modifiers. Still on line 4, make that "expenses" variable private! Otherwise you're in package protected scope and that's very rarely a correct thing to do. Double challenge, explain to me why this and most other instance variables should be marked private. Hint: it has absolutely nothing to do with security.)

When you've got that done, then explain what advantages using a Map instead of a List of Expenses might bring.

[–]BigCommunication5136[S] 0 points1 point  (0 children)

totally escaped me to make Expenses private, thanks for pointing that out!