• Post Reply Bookmark Topic Watch Topic
  • New Topic

Check for null string  RSS feed

 
krishna teja
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any other way to know if a string is null, a part from doing the


thanks
Krishna Teja D.V.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to do that? Using the if condition is what most people do.

The above code can also test if the String is null, but it's just silly. I doubt people will want to use that approach.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that a String cannot be null. A String reference can be null. Variables in Java are not objects, they are references to objects.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!