运算符在Java中重载和覆盖 [英] Operator overloading and overriding in Java

查看:201
本文介绍了运算符在Java中重载和覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运算符重载和运算符重写之间有什么区别?

What is the difference between operator overloading and operator overriding?

它们在继承和控制台程序中是否相同?

Are they the same in inheritance and console program?

推荐答案

Java不支持运算符重载和覆盖。

Operator overloading and overriding are not supported in Java.

检查以下引用的desc: http://java.sun.com/docs/white/langenv/Simple.doc2.html

Check following desc quoted from : http://java.sun.com/docs/white/langenv/Simple.doc2.html


2.2.7没有更多运营商超载

没有提供
程序员可以重载标准
算术运算符的方法。再一次,运算符重载的
效果可以通过声明
类,适当的实例变量,
以及操作
这些变量的适当方法轻松实现
。消除运算符
重载导致代码简化
简化。

There are no means provided by which programmers can overload the standard arithmetic operators. Once again, the effects of operator overloading can be just as easily achieved by declaring a class, appropriate instance variables, and appropriate methods to manipulate those variables. Eliminating operator overloading leads to great simplification of code.

这篇关于运算符在Java中重载和覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆