Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for null or "" value

Status
Not open for further replies.

eizofitz

Programmer
Dec 9, 2002
9
GB
Hi,
I'm new to working with Java and I'm wondering how do I check if a value (attlist) is empty.

I know how to check if it's equal to 'null'... i.e...

if(attList==null)

but I need to check if it's null OR empty and don't know the syntax for this. Is it something like...

if(attList==null || attList=="")

Thanks for the help in advance.
 
I'm not sure what type of object attList is, but if it is a String you can use the length() method:

if ( attList == null || attList.length() == 0 )

Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top