I have an interface.
public interface Module {
void init();
void actions();
}
What happens when i try to create an array like this?
Module[] instances = new Module[20]
How can i implement this array?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
yes, it is possible. You need to fill the fields of the array with objects of Type
Moduleinstances[0] = new MyModule();And
MyModuleis a class implementing the Module interface. Alternatively you could use anonymous inner classes:Does this answer your question?