Я кодирую в eclipse и впервые в java, унаследованный метод и вызываю родительский метод с ключевым словом super()
, показывающим ошибку в Java -8, также метод new Child();
также показывает ошибку. Имя файла: Пример. java
public class Example{
class Parent{
void parentMethod(){
System.out.println("Parent Method");
}
void parentMethod(int a){
System.out.println("Parent Method: One Argument");
}
void parentMethod(int a, int b){
System.out.println("Parent Method: Two Argument");
}
}
class Child extends Parent{
void childMethod() {
super(10);
System.out.println("Child Method");
}
}
public static void main(String[] args) {
new Child();
System.out.println("Main Class Method: no argument");
}
}
выдает ошибку в затмении:
in line 15: Multiple markers at this line
- Line breakpoint:Public$Child [line: 15] -
childMethod()
in line 20: No enclosing instance of type Public is accessible. Must qualify the allocation with an enclosing
instance of type Public (e.g. x.new A() where x is an instance of Public).
. ; .