[6047] in java-interest

home help back first fref pref prev next nref lref last post

How to check for null ....

daemon@ATHENA.MIT.EDU (Dhaval M Shah)
Mon Mar 18 14:19:46 1996

Date:         Mon, 18 Mar 1996 19:17:19 +1100
Reply-To: Java Interest <JAVA-INTEREST@JAVASOFT.COM>
From: Dhaval M Shah <dms03@CS.UOW.EDU.AU>
To: Multiple recipients of list JAVA-INTEREST
              <JAVA-INTEREST@JAVASOFT.COM>

To: java-interest@java.sun.com
Cc: owner-java-interest@java.sun.com

Hello Everybody,

I am a student with good 'C' background and trying to learn
java.

I have created a string that depending upon input either has some characters or
has "null" in it. [Or rather the string is null]

My problem is how to check for nullity in java. If the string has "null" and
I use mystring.length() in the hope that it should return 0, java throws
a runtime exception.

When I say System.out.println(mystring); it prints null.

In 'C', I could have done something like this :

if(mystring)                            /* Just a crude example */
        printf("\n string is not null);
else
        printf("string is null");

Is there any method (or) a specific way to check for strings with null in it.

Thanks

Dhaval

--
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
   Dhaval M. Shah
   dhaval@cs.uow.edu.au                 (Home) : +61 42 258519
   Dept. of Computer Science
   University of Wollongong             2/13 Catherine St., Gwynneville,
   NSW 2522     Australia               NSW 2500     Australia
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

home help back first fref pref prev next nref lref last post