This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to check whether string is null or not ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to check whether string is null or not ? " Watch "How to check whether string is null or not ? " New topic
Author

How to check whether string is null or not ?

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2904
    
    1

hi ranchers,

i am chcking a string for null , here is my code



What ll be possible cause, Is iterator making some problem, here ?

Thanks.

Regardz,
[ March 19, 2008: Message edited by: Sagar Rohankar ]

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20137
    
  30


You know, it hardly ever occurs that toString() returns null for an object; the objectitself is much more likely to be null. Therefore, you should check it.next() instead.

However, it.next() doesn't just return an object, it also goes ahead one step. To prevent this, you should cache the object:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to check whether string is null or not ?
 
jQuery in Action, 3rd edition