Java中的静态类有什么像static class在爪哇?这样一个阶级的意义是什么。静态类的所有方法是否都需要static也是?反过来,如果一个类包含所有的静态方法,那么该类是否也是静态的呢?静态类有什么好处?
3 回答
MYYA
TA贡献1868条经验 获得超4个赞
public class Test {
class A { }
static class B { }
public static void main(String[] args) {
/*will fail - compilation error, you need an instance of Test to instantiate A*/
A a = new A();
/*will compile successfully, not instance of Test is needed to instantiate B */
B b = new B();
}}添加回答
举报
0/150
提交
取消
