aspose file tools*
The moose likes Beginning Java and the fly likes How to Check for Null or Empty Value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to Check for Null or Empty Value" Watch "How to Check for Null or Empty Value" New topic
Author

How to Check for Null or Empty Value

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1391
I am using the following code section I to try and check for an empty or null value but it never is empty even though the string I send to it is blank.

marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

You can check for null using if(myRef == null) or if (myRef != null).

However, a "blank" or empty String ("") is not null. It's a String with a length of zero. You can check this using myString.length(), after you verify that the reference is not null.

[ August 30, 2007: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1391
Thanks, for the help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Check for Null or Empty Value
 
Similar Threads
Getting 0 rows returned when selecting with null values
String declaration
difficulty in understanding <jsp:forward page=" " />and unusual code execution.
Action form: data getting lost between form submit and setters on ActionForm
Null Compare