Layout Name is nullProperty Name is nullStart is 0 Length is 0
Regards
Sudhakar
Use .equals(...) to compare two objects, and make sure that your PropertyStore class imlements an equals(...) method.
Exception in thread "main" java.lang.NullPointerException
Regards
Sudhakar
The stack trace should tell you exactly what line this is occurring on, can you see which one?
Exception in thread "main" java.lang.NullPointerException
at xmlparser.PropertyStore.equals(PropertyStore.java:16)
at xmlparser.Main.main(Main.java:110)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Regards
Sudhakar
Sunil Kumar
> Think Witty <
Originally posted by Karnati Sudhakar:
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
You could use the removeAll method which I guess would only iterate thru the list once (but I haven't actually looked at the source to see if this is the case).Originally posted by Rob Prime:
You know, you can do the same using the methods in List and Collection in just one line:
Both your and my solution can be a bit slow though, as both start at 0 when finding the element to remove. If there are mulitple occurrances, both go through the entire list multiple times.
Joanne
Sunil Kumar
> Think Witty <
Originally posted by Sunil Kumar:
Hey Joanne/Rob .. both the implementations will require the equals method for PropertyStore to compare its methods in correct way. And with the current implementation of equals as provided by Karnati will always throw a NullPointerException as i mentioned above
Joanne
Hence you need a null check to compare any objects (in your case String)
Exception in thread "main" java.lang.NullPointerException
at xmlparser.PropertyStore.equals(PropertyStore.java:16)
at java.util.ArrayList.indexOf(ArrayList.java:220)
at java.util.ArrayList.contains(ArrayList.java:201)
at java.util.AbstractCollection.removeAll(AbstractCollection.java:353)
at xmlparser.Main.main(Main.java:110)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
Regards
Sudhakar
Sunil Kumar
> Think Witty <
Consider Paul's rocket mass heater. |