In Java, we use Interface to hide the implementations from users. Interface contains only abstract methods and as abstract methods do not have a body we can not create an object without constructor. Something like this
public interface ExampleInterface {
}
public class Example implements ExampleInterface {
private static void main(String[] args) {
// This is not possible
ExampleInterface objI = new ExampleInterface();
// However this is
ExampleInterface[] arrI = new ExampleInterface[10];
}
}
My question is why Java allows creating an array of object Interface and where someone might use it? Is is a good coding practice to use it or it is better to create a concrete class that implements the interface and then create an array of that class.