I have a question about interface and class implementing interface.
This is my code:
interface iMyInterface {
public iMethod1();
}
public class cMyClass implements iMyInterface {
public iMethod1() {
// some code
}
protected iMethod2() {
// some code
}
}
I would like to create an instance of iMyInterface as this :
iMyInterface i = new cMyClass();
i.iMethod1();
It's ok, but how can I call iMethod2() from my interface instance? Is this working and safe:
((cMyClass)i).iMethod2();
Thanks for help.