If (a && b)

I have the code below:
if (a && b) {
c;
Both expressions a and b are very lengthy and consume much processing power. What I want to know is: if the expression a returns false, does it even check the expression b?
Or is it any better to switch the code to:
if (a) {
if (b) {
c;
Is there any real difference?
Thanks in advance!

if the expression a returns false, does it even check the expression b?easy enough to test
class Testing
  int a = 0;
  int b = 0;
  public Testing()
    if(a() && b()) System.out.println("both true");
    System.out.println("a = "+a);
    System.out.println("b= "+b);
  public boolean a()
    a++;
    return false;
  public boolean b()
    b++;
    return true;
  public static void main( String[] args ){new Testing();}
}if you DO want both evaluated
if(a() & b())

Similar Messages

Maybe you are looking for

  • Office web Apps preview of SharePoint 2010 source in SharePoint 2013 search results

    Hi Team, We have crawled SharePoint 2010 source in SharePoint 2013 and able to get results successfully. Now our requirement is to show Office Web Apps previes of 2010 documents in 2013 search results. Any guidance on this please. Thanks, Manjeera

  • Getting Java.Lang.NullPointerException

    Hi, I am getting java.lang.NullPointerException when calling the 'validate' method. Appreciate any help. Thanks import com.sun.net.ssl.internal.ssl.Provider; import java.io.*; import java.net.URL; import java.net.URLEncoder; import java.security.Secu

  • What is the Max import file size for Aperture

    I'll some times shoot film and get very large scans done as Tiffs or Jpegs. 500MB+ What is the Max that Aperture can manage, or is it only determined by the Mac configuration?

  • Retina macbook HDMI issues...

    Hi Ive recently bought a retina macbook and its  an outstanding piece of kit. Unfortunately I've come accross a little glitch with the HDMI port If i plug in my TV via hdmi, the connection temporarily cuts when I move the machine arround . Im just wo

  • Common Header in each page in WP8

    Hi, I am creating a Windows Phone application.I have a common header that I have to display in each page.Is there a way to create a common UI that could be included in every xaml page.If yes, then how can I do it?