How to resolve 'Implicit super constructor classA() is not visible. Must explicitly invoke another constructor'?

前端 未结 4 1391
[愿得一人]
[愿得一人] 2020-12-17 17:12

I am having a class \'ClassA\' which is having private constructor.

public final class ClassA{
  private ClassA{
  }

  public static void main(String[] arg)         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-17 17:13

    Java will implicitly create a constructor with no parameters for ClassB, which will call super(). In your case the constructor in ClassA is not visible, hence the error you are getting. Changing the visibility to public or protected will resolve the error.

提交回复
热议问题