The main problem: in Java, operators like "+" and "-" are allowed only for primitive types (for example, byte, int, long), but not for objects (in general) and arrays.
Other languages ββallow operator overloading, so in C ++ you can define the "+" operation for Point objects, and your original idea will compile and execute. But this is not possible in Java.
The only exceptions are String (this allows you to add String objects) and primitive wrappers such as Integer and Double in Java 1.5+ (autoboxing converts them back to primitives)
source share