Default constructors in Java

前端 未结 7 1737
南旧
南旧 2020-12-09 07:21

I know I\'m asking some serious 101 question here...

I have some class Foo and a class Bar that extends Foo. In Foo

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 07:46

    JVM will not provide a default constructor if you have provided one due to design reasons. What you can do define constructor in Bar with same signature and call super().

    public Bar(int x,int y) {
        super(x,y);
    }
    

提交回复
热议问题