Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Null pointer not found  RSS feed

 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok somebody explain this-

output:
 
john von
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
explain what?
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the following throws java.lang.NullPointerException
s=null;
s=s.concat("a");

How come this
("1"+null+2) does not?

And also in other places.

Am I correct in thinking this is because internally a StringBuffer is used in all cases and stringBuffer.append(null) just adds the text null.
Anyway I thought it was interesting because I was expecting a nullpointer to be thrown and it was not.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!