Hello
How check all purchase using methos equals without operator if.
I have next code:
for(Purchase purchase : listShop) { //output in console System.out.println(purchase); //found max cost purchase if(purchase.getCost() > maxCost) { maxCost = purchase.getCost(); } //check equals all purchase if(equalResult) { equalResult = purchase.equals(listShop[0]); } } }
How change without if: if(equalResult)
{
equalResult = purchase.equals(listShop[0]);
}