As I understand from reading multiple posts here in SO, Java's compiler implements the operators overloading for objects, so that when it sees a simple expression like Integer i = a + b (let a and b be of type Integer, too), it compiles it as a call to the Integer.valueOf() function (as explained here).
I'd like to know how a Java compiler implements this. I mean, does it have a Java C++ [edited according to comments] code underneath that uses a simple operator overloading, so that when seeing a binary + operator with Integer it calls the valueOf() function?
Also, this link appeared in one of the SO answers (sorry, I can't remember where), and I thought maybe the enterBinop part is related to this issue?
CorC++orDor any other language. The Java compiler (as provided by Oracle's JDK) is written in Java. How actual addition is done at runtime is another question entirely, and comes down to JVM bytecode and CPU opcodes.Integer a = 1, b = 3; a = a+b;it should do some specific operation, and when seeing something likeString s = "he" + "llo";it should do something else, handling the+differently this time. Isn't that operator overloading?