abstract class Manager {
static void test() {
System.out.println(12);
}
class Manager1 {
public static void main(String args[]) {
System.out.println(Manager.test());
}
}
}
It's producing a compile time error. Can an abstract class have a static
method with void
type?
Non-static inner classes cannot have static
methods - only top-level and static classes can (as per JLS §8.1.3 ).
Furthermore:
System.out.println(Manager.test());
Manager.test()
is void: you can't print that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.