Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

TreeSet Problem

 
Nathan Doe
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Report post to moderator
In a project i'm working on I have to take a census .txt file containing names and put it into a "NameRank" (which holds the name, and information about the national ranking of the name) after I put the file into an Array of NameRanks. The next part I have to create 5 data structures - ArrayList, HashSet, LinkedList, TreeSet, and Vector and put the info. from the NameRank Array into each and bench mark the time it takes to complete the whole process. I wrote my code and it all works except when I try to add something to the TreeSet that i have created using:


when it gets to adding the file from the array I get this error:



The line that it is generating this exception is in this loop:



For every other data structure it works when this is commented out.

- Nathan
 
Henry Wong
author
Marshal
Pie
Posts: 21000
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Seems to be a duplicate topic...

http://www.coderanch.com/t/466947/Java-General/java/Implementing-Comparable-Interface-with-TreeSets

And it looks like that EFH gave you the exact instructions on how to hunt down the NPE. What is it that you don't understand? But post in that topic, as I am closing this one.

Henry
 
    Bookmark Topic Watch Topic
  • New Topic