The first parameter of the main method is a file name.
Each line of the specified file has the following format:
name value
where [name] is a String and [value] is a double. [name] and [value] are separated by a space.
Find the sum of all the values for each name.
Display all the data, sorted by na
Calculating salaries
- 12
Locked
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
Олег БайбулаExpert
5 March, 07:12
It's awkward using Double here instead of BigDecimal. Consider the next example if you don't agree:
0
Justin Smith
7 November 2021, 13:09
CodeGym hasn't formally introduced TreeMap in the lessons yet, but it makes this rather easy. You should be familiar with it at this point, and if not I recommend googling how it works. It's just like HashMap but auto-sorts by key.
+1
Олег БайбулаExpert
5 March, 05:13
And you should use Stream API.
+1
Trevor
31 January 2020, 20:12
Use a TreeSet and pass a comparator to sort your values :)
+1
Henrique
1 July 2020, 17:34
Using your idea of a TreeSet, I used a TreeMap and it worked as well (with no need of a comparator).
0