I have a CSV file which I read through a parser like superCSV. I have about 5000 records in it. I am able to put all values in the HashMap and but while iterating through it, it only displays 10 records instead of all of them. What can be the reason? I have a HashCode for Map's values in another class alongwith the equals method. Unable to understand why that might be since all the records of csv file are read perfectly by the parser. Any help is appreciated. Thank you.
Asked
Active
Viewed 39 times
0
-
remove hashcode and equals method and execute again you will get 5000 count. or try arraylist if you think duplicates you also want to store. – prashant thakre Aug 20 '15 at 16:09
-
@prashantthakre On removing it stays the same. Nothing changes. I noticed map only has tthose 10 records but I am able to read them correctly. – user3044240 Aug 20 '15 at 16:19
-
Why don't you post a small code example? That will help us help you :) – James Bassett Aug 21 '15 at 11:49
1 Answers
0
maybe you wrongly count a hash of one item and you override values in hashmap.
Example. You get a 5000 contact, but you count hash by name and you have 5000 "John" then when you will iterate you will get just one item.
Please check that.
hash and equals implementation.

mariopce
- 1,116
- 9
- 17
-
I generated the default hashcode and equals method which IDE provides. I noticed map has only those 10 values but I did read all of them and put them in map as I was reading through the csv file. Anything? – user3044240 Aug 20 '15 at 16:20
-
I misunderstood your comment but I think I get it now. I do have a column in my file which has duplicate values and it is also included in equals and hashcode methods. But I want to compare that column with its counterpart in other file so I do need that column, even with duplicate values to be compared. So what would your suggestion be? Thanks. – user3044240 Aug 20 '15 at 17:44
-