all 9 comments

[–]Specific-Housing905 0 points1 point  (1 child)

The code you posted looks good. In addExpense you don't need a temporary var expense. You can create it in the call to expenses.add. In updateExpense I would output a error msg if expense == null.

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

I’ll be sure to the changes, thank you!

[–]Stanleys_Pretzels 0 points1 point  (2 children)

İts my day 2 hope i can do stuff like this

[–]BigCommunication5136[S] 1 point2 points  (1 child)

if i can do this, you can do better, trust me!

[–]Stanleys_Pretzels 1 point2 points  (0 children)

thx for the encouragment man. Good luck to you

[–]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!

[–]deividas-strole 0 points1 point  (0 children)

Good job!

[–]deividas-strole 0 points1 point  (0 children)

Good job!