In Java 6 == 24

TIL that in Java 6 == 24. Let's see how and why.

The how

Let's run the following:

System.out.println(2 + 4 + " == " + 2 + 4);

You would expect an output like:

6 == 6

However, the actual output is:

6 == 24

The why

Well, once Java finds a String in a System.out statement, it treats the remaining arguments also as a String. 🙂


SHARE THIS ARTICLE