为什么静态方法在Java中不能是抽象的 [英] Why can't static methods be abstract in Java

查看:124
本文介绍了为什么静态方法在Java中不能是抽象的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题在于Java为什么我不能定义一个抽象的静态方法?例如

The question is in Java why can't I define an abstract static method? for example

abstract class foo {
    abstract void bar( ); // <-- this is ok
    abstract static void bar2(); //<-- this isn't why?
}


推荐答案

因为摘要是指: 实现无功能,静态意味着:即使您没有对象实例也有功能。这是一个合乎逻辑的矛盾。

Because "abstract" means: "Implements no functionality", and "static" means: "There is functionality even if you don't have an object instance". And that's a logical contradiction.

这篇关于为什么静态方法在Java中不能是抽象的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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