That's pretty curious; I would never have thought to do this, and wonder why
you are.  Anyway, it seems pretty obvious that s1 == <empty String> + null
and s1 != null, so it fails the s1 == null test.  You, of course, cannot see
the System.out.println of an empty String, with or without a null
concatenated.

Mark

-----Original Message-----
From: Jagdish Arora [mailto:[EMAIL PROTECTED]] 
Sent: Friday, January 17, 2003 3:31 AM

ok, though this problem came up dealing with ActionForms, I completely
understand that this is a fundamental Java question, nothing more, so I will
pose it as that only.  Also, I am prepared for taking some
thisQuestion(OrYou)DoesntDeserveToBeHere flak:

        String s1 = "" + null;
        System.out.println ("s1: " + s1);
        if (s1 == null)
            System.out.println ("s1 is null");
        else
            System.out.println ("s1 is not null");

produces output:
        s1: null
        s1 is not null

While if I replace the first line by, String s1 = "";
then it produces output:
        s1:
        s1 is not null

(which I have no problem with).

Question: Why does the 1st line of the output of the first case read s1:
null  ?

Amrinder

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to