Hello everyone.
I have an interesting question to ask. I have seen on a few forums that
operator overloading is not possible in Java. So then, why can we use the following?
Integer a = new Integer(1);
Integer b = new Integer(2);
Integer c = a + b;
I've tested this and it seems to work. Could this be due to Java's auto-boxing? In this case a, b and c are all instances of Integer. And the + means the addition of two Integer objects, which then returns an Integer object. Could it be that the objects, a and b, are converted to their primitive type equivalents, added and then converted back to an Integer object?
Just a strange thing I picked up. Thank you.
