posted 18 years ago
Code Snippet:
the code above loops through a map and prints out a list of Station. i.e.
depending on a map given, i sometimes get a duplicate station, i.e. "Finchley" would be printed twice somewhere in the list... so to make a unique list
i decided to use HashSet and use its add method to add all the element to the set.
Say i declare a HashSet someSet as an instance member right at the top of my code...
then in the code given i replace //HERE with someSet.add(s);
this compiles fine but when executed it causes my code to throw NullPointerException any idea why this is happening? and the compliler say that the exception is caused by the line someSet.add(s);
thanks
[ September 25, 2006: Message edited by: Firman Drage ]