How to create an instance of a class which is actually an array?
the following code gives a runtime exception
Object obj = (Object )attributeClass.newInstance();
Exception:
java.lang.InstantiationException: [Ltest.Name;
Here test.Name is user defined class and i want to create an array instance of that class.
I have tried the following also:
Object methodArgs[] = new Object[length];
for(int j=0;j<length;++j){
methodArgs[j] = singleMemberClass.cast(testArray[j]);
}
Object temp = attributeClass.cast(methodArgs);
In the above codesingleMemberClass is test.Name, but the last line gives the following exception.
java.lang.ClassCastException
Message was edited by:
lalit_mangal
Message was edited by:
lalit_mangal>

