I work with inheritance when I encounter such a problem. my code is as follows
public class Parent {
public void methodParent() {
System.out.println("Parent");
}
}
public class Child extends Parent {
public void methodParent() {
System.out.println("override method in Child");
}
public void methodChild() {
System.out.println("method in Child");
}
}
public class MainTest {
public static void main(String[] args) {
Child[] c = new Child[10];
Parent[] p = c;
p[0] = new Parent();
c[0].methodParent();
}
}
stack trace
Exception in thread "main" java.lang.ArrayStoreException: com.test.Parent
at com.test.MainTest.main(MainTest.java:10)
when i debug check c then i got a message like
org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.
please help me understand what the problem is.
source
share