public class TestPass {
int a,b;
TestPass(int i,int j)
{
a=i;
b=j;
}
boolean equals(TestPass o)
{
if(o.a==a&&o.b==b)
return true;
else
return false;
}
}
class Test
{
public static void main(String[] args)
{
TestPass ob1=new TestPass(100, 22);
TestPass ob2=new TestPass(100, 23);
System.out.println("Condition="+ob1.equals(ob2));
}
}
Output:
Condition=false
I cannot find the logic with this output,bcoz 'if(o.a==a&&o.b==b)' code is used AND short circuit operator(&&),it only checks left hand side of operator(i think so).
TestPass ob1=new TestPass(100, 22);
TestPass ob2=new TestPass(100, 23);
Here i gave different values,but i think AND short circuit operator(&&) only checks left hand side,my expected output is True!,I think i'm wrong.I need clarification, Expect your help.