I've created a Vector class and want to add be able to add the Vector's X and Y by just doing
Vector a + Vector b
Is it possible to do this in Java?
I've created a Vector class and want to add be able to add the Vector's X and Y by just doing
Vector a + Vector b
Is it possible to do this in Java?
Sorry, but you cannot define or overload operators in Java. Implement an add method. You can have the add method return this, to allow chaining of operations (e.g., sum = a.add(b).add(c)), but that does not always result in the most readable code.