[英]Why can't static methods be abstract in Java?
The question is in Java why can't I define an abstract static method?问题是在 Java 中为什么我不能定义抽象静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
有一种情况可以一起使用 static 和 abstract ,那就是这两个修饰符都放在嵌套类的前面。
Static Method A static method can be invoked without the need for creating an instance of a class.A static method belongs to the class rather than the object of a class.静态方法 可以在不需要创建类的实例的情况下调用静态方法。静态方法属于类而不是类的对象。 A static method can access static data member and also it can change the value of it.
静态方法可以访问静态数据成员,也可以更改其值。 Abstract Keyword is used to implement abstraction.
Abstract关键字用于实现抽象。 A static method can't be overriden or implemented in child class.
不能在子类中覆盖或实现静态方法。 So, there is no use of making static method as abstract.
因此,将静态方法设为抽象是没有用的。
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
The question is in Java why can't I define an abstract static method?问题是在Java中为什么不能定义抽象的静态方法? for example
例如
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.