Operator overloading in Java

Viewed 235041

Please can you tell me if it is possible to overload operators in Java? If it is used anywhere in Java could you please tell me about it.

10 Answers

Unlike C++, Java does not support user defined operator overloading. The overloading is done internally in java.

We can take +(plus) for example:

int a = 2 + 4;
string = "hello" + "world";

Here, plus adds two integer numbers and concatenates two strings. So we can say that Java supports internal operator overloading but not user defined.

Related