• Post Reply Bookmark Topic Watch Topic
  • New Topic

Operator overloading  RSS feed

 
Bablu Gope
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As we know java is not supported operator overloading but plus symbol(+) is used as the concept of operator overloading why?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The Java language has indeed overloaded the plus operator for both string concatenation and fixed (and floating) point arithmetic.... but that doesn't mean that Java supports operator overloading. To do that, the language would need to allow you to define your own behaviors to the operators.

Henry
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are other overloaded operators; for example & ^ | are bitwise operators overloaded to operate on booleans. But as Henry says, you cannot do your own overloading.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!