Arithmetic Exception Equality Check
public static boolean isEqual(int a, int b) { try { int c = 1 / (a - b); } catch (ArithmeticException e) { return true; } return false; }
A Java method checks whether two integers are equal by dividing 1 by their difference. When the numbers are equal, the division causes an ArithmeticException, so the catch block returns true; otherwise it returns false. The joke is the absurdly indirect and overcomplicated way of implementing a simple equality check, making it a reaction for bad code or cursed programming logic.
- @ithueti / 387 2018-09-06
- @profunctor_io / 1737 2019-03-04
- @right_wing_dev_squads / 2438 2021-08-30
- Type
- image
- Size
- 429×213 · 15.3 KiB
- Mood
- absurd, sarcastic
- Language
- en
- Added