I am trying to make an checkFalse method where i take Object as an argument. I now want to check if that Object is the same type as this.getClass(). If it is of the same type, i now want to cast the Object to that class in order to access the methods of that object class!
For example, how can i access the SomeMethod from that f object? I am trying to convert the object F to the class testMain.
Error: Cannot be cast to testMain
class testMain implements testest
{
}
interface testest
{
public default boolean SomeMethod()
{
}
public default boolean checkFalse(Object f) throws ClassCastException
{
try
{
f = this.getClass();
}
catch (ClassCastException exception)
{
throw exception;
}
f = (testMain)f; //Here. How do i turn this object to the class testMain so that i can access that objects methods? For example, how can i access the SomeMethod through this f object?
}
}
testest(nottestMain). By the way: Stick to the Java code conventions, and write class and interface names inCamelCase.testestgives you the error "cannot be cast to Queue" ???