当前位置:   article > 正文

java 不能重载,Java不能重载任何运算符。为什么?

java为什么不能重载运算符

In c++, we can perform the operator overloading. But Java is also a Object oriented language. So why java doesn't support overloading?

解决方案

Actually, it does support operator overloading... of a very limited, built-in only nature. For instance "+" is overloaded for String's in addition to the usual arithmetic.

Of course, most people want to know why Java does not support user-defined operator overloading. :-) The simplest answer seems to be that the Java creators did not, at the time, see any clean way to add it to the language without making Java a mess (like C++) in the process.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/468033
推荐阅读
相关标签
  

闽ICP备14008679号