X
X
Xenosx2020-12-16 16:01:32
Java
Xenosx, 2020-12-16 16:01:32

JAVA, negative values ​​are incorrectly considered in Map, why so?

The TXT key values ​​are space-separated pairs, each pair has a new line. If Keys in txt are repeated, then values ​​are summed up.
Roughly speaking, here is an example.
Ivan 3
Ivan 3.40
So the map should have Ivan 6.40
Nothing could be easier, I implemented it through
map.put(line.substring(0, index), Double.parseDouble(line.substring(index,endInex))); Where index is a space and endIndex is the end of the line.
Everything works with positive numbers, but completely refuses with negative ones. If there is
Ivan 12
Ivan -3
Then instead of 9, Ivan will have -3 in the map. Why is that?
How to implement it correctly?
I will be very grateful!!!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question