Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Hi All, I am getting Null Pointer error while trying to set an array of objects for the following getter setter class.
I am relatively new to Java, can someone help me to find out the right way to do this.
If you are getting an error, please post it, in its entirety here. Those error messages tell you EXACTLY where the problem is. Your job when posting here is to make it as easy as possible for us to help you, and posting that message is a basic requirement.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Prasad prap wrote:Remember null pointer exceptions are always due to no object creation.
"Always" is a little strong, Prasad. null can be assigned as well:
And, one should not be confused into thinking that "null" is somehow an illegal value for an object variable to have in it, or even pass to another object's methods. For example:
Gets you this:
You know, I would love to get my hands on the person who decided to name that one NullPointerException. C/C++ programmers who learn Java all have to come to terms with the words, "there are no pointers in Java." (Well, I had to, anyway.) Object variables with null in them are part of what a Java programmer has to understand. Tossing error messages with the word "pointer" embedded in them at a new Java coder just adds to the confusion.
"Il y a peu de choses qui me soient impossibles..."
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
Free, earth friendly heat - from the CodeRanch trailboss