你能用Java编写虚函数/方法吗? [英] Can you write virtual functions / methods in Java?

查看:140
本文介绍了你能用Java编写虚函数/方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Java中编写虚拟方法,就像在C ++中一样?

Is it possible to write virtual methods in Java, as one would do in C++?

或者,是否有适当的Java方法您可以实现哪些产生类似的行为?我可以举几个例子吗?

Or, is there a proper Java approach which you can implement that produces similar behavior? Could I please have some examples?

推荐答案

来自 wikipedia



From wikipedia


Java 中,所有非静态方法是
默认虚拟功能。只有
方法标有关键字最终
无法覆盖,以及
隐私方法,不是
继承,非虚拟

In Java, all non-static methods are by default "virtual functions." Only methods marked with the keyword final, which cannot be overridden, along with private methods, which are not inherited, are non-virtual.

这篇关于你能用Java编写虚函数/方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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