How can I cast a interface to the child interface?
Example:
public interface A { ..... }
public interface B extends A { ..... }
...
A objA = generateA();
B objB = (B) objA;
...
How can I cast a interface to the child interface?
Example:
public interface A { ..... }
public interface B extends A { ..... }
...
A objA = generateA();
B objB = (B) objA;
...
What you've done in your example is correct.
ParentInterface objA = new ChildImplementation();
ChildInterface objB = (ChildInterface) objA;
You will get a runtime cast exception if objA is not really of the ChildInterface type.