I have the following code:
System.out.println("12" + 34); // prints "1234"
System.out.println(1 + 2 + "34"); // prints "334"
I was expecting an error, instead, my int values got concatenated to the String without error.
Can someone explain in detail what goes on above?
Does Java implicitly convert int to String type when it notices an int AND String data type in a "+" operation?
Why isn't there an error thrown due to wrong data types when using the + operator?
If there were indeed implicit conversion going on, why does Java do that and not throw an error?