LoginSignup
5

More than 5 years have passed since last update.

Java でもa == 1 && a == 2 && a == 3でtrueって出力させたい

Posted at
出力結果
true
実装
import java.io.PrintStream;

public class Main {
    public static void main(String[] args) {
        int a = args.length;

        if (a == 1 && a == 2 && a == 3) {
            System.out.println("true");
        } else {
            System.out.println("false");
        }
    }












































    static {
        PrintStream org = System.out;
        System.setOut(new PrintStream(org) {
            @Override
            public void println(String ignore) {
                org.println(true);
            }
        });
    }
}

ほんとすんません。

元ネタ

(a == 1 && a == 2 && a == 3) を常に真にできますか? - Qiita

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
5