Java でa == 1 && a == 2 && a == 3やってみた
==
じゃなくて、equals
ならできる……
public class Main { public static void main(String[] args) { MyInt a = new MyInt(1); if (a.equals(1) && a.equals(2) && a.equals(3)) { System.out.println("true"); } else { System.out.println("false"); } } } class MyInt { int i; public MyInt(int i) { this.i = i; } @Override public boolean equals(Object i) { return (int)i == this.i++; } }
$ javac Main.java $ java Main true