answersLogoWhite

0

'&&' is used for short-circuiting boolean expressions, which means that it will stop evaluating if the first operant is false but '&' won't.

This can be easier understood with an example:

int i = 0;

if( i < 10 && i++ < 20)

{

//some fancy stuff in here

}

first operant: i < 5

second operant: i++ < 20

In this case (using '&&'), if the first operant is evaluated to be false, it will stop and does not continue to evaluate the second operant.

If '&&' was replaced by '&,' even if the first operation is evaluated as false. It will still continue to evaluate the second operant before evaluating that the whole boolean is false, thus taking more time.

User Avatar

Wiki User

14y ago

What else can I help you with?