aspose file tools*
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
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: 2902
    
    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: 19785
    
  20


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
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 ?