No, Java does not expand this way. You cannot add operators, and you cannot even overload built-in operators such as +
. Even standard library classes, such as BigInteger, must use methods such as add()
, rather than operators like +
.
Scala (another static JVM language) will go around this using method calls rather than built-in operators, and resolving any characters in method names, so you can define new methods that seem to be operators, i.e.
a + 1
- syntactic sugar for:
a.+(1)
source share