This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException

 
Lio Liov
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have null pointer exception and My code ,could you help fixing it
Thanks

 
Koen Aerts
Ranch Hand
Posts: 344
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stacktrace would help.
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The String array is never instantiated. It is explicitly set to null, and is still null when you try to write a String to one of its indices.
 
Lio Liov
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ,can I instantiate the array without specified the size
 
Stefaan Dutry
Ranch Hand
Posts: 32
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lio Liov wrote:can I instantiate the array without specified the size


I would suggest looking at, and using ArrayList.
Especialy it's add method and it's toArray method.

Although i can't think of a reason to convert it to an Array again in this case.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic