Hi Friends......
I want to know,What can go wrong if you replace && with & in the following code:
String a=null; if (a!=null && a.length()>10) {...}
Thanks.........
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Dec 19, 2011, 11:33 PM
A single & will give a NullPointerException.
&& means that if the condition on the left is false it won't check looking at the condition on the right, if you use a single & instead it will force it to evaluate both conditions.
Thanks
Vikas MishraPosted Dec 20, 2011, 11:32 AM