I am working with inheritance while i encounter such 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 is
Exception in thread "main" java.lang.ArrayStoreException: com.test.Parent
at com.test.MainTest.main(MainTest.java:10)
when i debug inspect c then i got 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 to understand where is the problem.
org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.please help why this error occurs at runtime and resolves automatically.