When evaluating the expression System.out.println("100" + 1);
, it's important to understand how string concatenation works in Java. In this case, the first operand is a string ("100"), and the second operand is an integer (1).
In Java, when the '+' operator is used and one of the operands is a string, the other operand is converted to a string as well. Therefore, the integer 1 is converted to "1". Once both operands are strings, they are concatenated together.
So, "100" concatenated with "1" results in "1001". This is why the output of the statement will be "1001".
This behavior differs from numerical addition, where two numbers would be added together to produce 101, but because of the string context of the first operand, concatenation takes precedence, resulting in the final output.