Hi,
What Aman is saying is correct.Second part will never be performed.
But I was wondering what Rahul is saying that His code is printing literal "first2".How will print it b'coz It returns false so it will not print immediate print statement.It will skip to next statement and it prints literal "Hello world"
Thanks
Netla
Originally posted by Rahul Mahindrakar:
Hi,
You are right in your answer
I enclose the program below to conform what i say.
class demo
{
public static void main(String[] args)
{
String s=null;
//System.out.println("first");
//if ((s != null) & (s.length()>0))
//System.out.println("first1");
if ((s != null) && (s.length()>0))
System.out.println("first2");
//if ((s != null) | (s.length()>0))
//System.out.println("first3");
//if ((s != null) | | (s.length()>0))
//System.out.println("first4");
System.out.println("Hello World!");
}
}
The program compiles sucessfully and at runtime prints out first2 sucessfully.
Regds.
Rahul.
[This message has been edited by Netla Reddy (edited July 31, 2000).]
[This message has been edited by Netla Reddy (edited July 31, 2000).]