Forum Stats

  • 3,722,784 Users
  • 2,244,413 Discussions


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Is there any way to do operator overloading in java

I know that java doesn't support operator overloading, but isn't there any way we can use it? On google I couldn't find only one site that says it is possible using scala. I don't know how that would work.


  • Roland Mueller
    Roland Mueller Member Posts: 77 Blue Ribbon

    To not have operator overloading is an explicit design decision for Java language.

  • nihitthakkar
    nihitthakkar Member Posts: 96 Red Ribbon

    Java don't support user-defined operator overloading. The only aspect of it is to handle the + for strings, which either results in compile-time concatenation of constants or execution-time concatenation using StringBuilder/StringBuffer. Operator overloading allows you to do something extra than what for it is expected for.

Sign In or Register to comment.