Jump to content


Check out our Community Blogs

Yonatan

Member Since 19 Jun 2012
Offline Last Active Feb 06 2013 10:03 AM
-----

#632043 Substitute For An "and" Statement Inside Of An If?

Posted by Yonatan on 19 June 2012 - 02:00 PM

Please notice that & and && are different,
& is a simple conjunction.
&& will stop test in case of false.

So for example if I have the string parameter and I want to check:
if(parameter==null) and if(parameter.contains("apple"))

It will be incorrect to use & because you cant test the second condition if parameter is null.
so I will do:
if(parameter==null && parameter.contains("apple"))
      //do something

  • 1


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download