System.out.println(true + "hello" + 3); //fine
System.out.println(2 + (2 >= 2) + 3); //exception
System.out.println(2 + true + "hello" + 3); //exception
Jshell console:
jshell> /open C:\WSs\to-learn\deleteLater.java
truehello3
| Error:
| bad operand types for binary operator '+'
| first type: int
| second type: boolean
| System.out.println(2 + (2 >= 2) + 3);
| ^----------^
| Error:
| bad operand types for binary operator '+'
| first type: int
| second type: boolean
| System.out.println(2 + true + "hello" + 3);
| ^------^
jshell>