Java error: Implicit super constructor is undefined for default constructor

前端 未结 10 1101
借酒劲吻你
借酒劲吻你 2020-11-22 10:28

I have a some simple Java code that looks similar to this in its structure:

abstract public class BaseClass {
    String someString;
    public BaseClass(Str         


        
10条回答
  •  不要未来只要你来
    2020-11-22 11:05

    Another way is call super() with the required argument as a first statement in derived class constructor.

    public class Sup {
        public Sup(String s) { ...}
    }
    
    public class Sub extends Sup {
        public Sub() { super("hello"); .. }
    }
    

提交回复
热议问题