Is it possible to typecaste interface object at runtime in java using dependency injection?
public interface Animal { void speak(); } public class Dog implements Animal{ void speak (){ System.out.println(“This is dog.”) } } public class Cat implements Animal{ void speak (){ System.out.println(“This is cat.”) } } @Module public class Module{ @Provides @Named(“Dog”) static Animal providesDog() { return new Dog(); } @Provides @Named(“Cat”) static Animal providesCat() { return new […]