suppose i have the following code
E[] arrayVar = (E[])new Object[1];// It causes a compiler warning
the question is, in what situation when the code will cause a run time error,
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.
That code will only cause a runtime error if you try to assign the result to the reified type of
E:The safe way to create generic arrays is with the use of
Array.newInstance:This method will not cause a
ClassCastException.