aspose file tools
The moose likes Beginning Java and the fly likes NullPointerException creating Liist from XML Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "NullPointerException creating Liist from XML" Watch "NullPointerException creating Liist from XML" New topic
Author

NullPointerException creating Liist from XML

John Bates
Greenhorn

Joined: May 31, 2012
Posts: 9
Hi, i am having trouble when creating a List of object Items from the entries in the XML file. i am getting errors output
----------MY CODE-----------------





// <-- -- if i remove this line its writing the xml file with out the object items of xml.. but if i include this line my output is getting errors


-------------------------OUT_PUT-------------------------------------

Exception in thread "main" java.lang.NullPointerException
at javaapplication5.NewMain.main(NewMain.java:30)
Java Result: 1
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Something in that line is null. You need to find out what. I would put newSegments high on the list of suspects.

Why are you using small letters and names like fg for the names of types? Why are you casting the returned value in the second line?

And welcome to the Ranch
John Bates
Greenhorn

Joined: May 31, 2012
Posts: 9
Thanks Campbell Ritchie,

I found out the reason for this, as you suggested line is null. and here it was returning class, and i can never cast a class to List in any way.

Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Well done
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException creating Liist from XML
 
Similar Threads
converting XML with XSLT
equals() method and == operator
Populating Country Values in combobox using spring form tags
Populating Country Values in combobox using spring form tags
How to align mutliple columns properly using print?