I have an Object[] in Java and want to convert it to IProject[], which is a Java interface (org.eclipse.core.resources.IProject), in order to write a plugin for eclipse.
Is this possible?
Regards
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.
You can’t convert the array itself – arrays know the type of their slots, so you can’t just cast an instance of
Object[]to an expression of typeIProject[], even if the array happens to contain only instances ofIProject(unless you happen to have a variable of typeObject[]which actually points to an instance ofIProject[]).Instead, you’ll need to make a new array with the same contents:
Array stores are dynamically type-checked, so if your
Object[]contains any objects which are not instances ofIProject, you’ll get anArrayStoreException.