Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes TreeSet Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

TreeSet Problem

Nathan Doe

Joined: Oct 17, 2009
Posts: 24
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

Joined: Sep 28, 2004
Posts: 20534

Seems to be a duplicate topic...

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.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: TreeSet Problem
It's not a secret anymore!