Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointerException creating Liist from XML  RSS feed

 
John Bates
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 56597
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 56597
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!