Tuesday, July 29, 2008

Java operators

The following might be very familiar to you, but for me it was completely new.

Will the following compile, if yes, what will be the output and why? Any exceptions? If it doesn't compile, why?

String s = null, s1 = null;
System.out.println(s != null && s.length() > 0);
System.out.println(s != null & s.length() > 0);

Whats going on in the above code?

No comments: