I want to call a subclass function in another class in java. How to do it?
An example is my superclass and subclass.
public abstract class a
{
method 0;
}
class b extends a
{
method 1;
}
There is another class call c. I want to do the following operation in class c. C is another class in a new file. But in the same package.
class c
{
c val;
public c
{
a var1 =( (b)val.method0()).method1;
}
}
but I got an exception when starting the program, indicating that the type can not cast a for type b. Does anyone have a suggestion to get rid of this?
Here is the actual exception error I received. (I wrote the code above as a demo)
"main" java.lang.ClassCastException: classfileparser.ConstantClass classfileparser.ConstantUtf8 at classfileparser.ClassFile. (ClassFile.java:50) classfileparser.ClassFileParser.main(ClassFileParser.java:18) C:\Users\Dave\AppData\Local\NetBeans\Cache\8.2\-\run.xml: 53: Java : 1 BUILD FAILED ( : 0 )