How remove the:
Type safety: The expression of type
List[] needs unchecked conversion to conform toList<Object>[]
compiler warning in the following expression:
List<Object>[] arrayOfList = new List[10];
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.
Afaik the only way is to use
@SuppressWarnings("unchecked"). At least if you want to avoid the raw type warning that occurs in Matthew’s answer.But you should rethink your design. An Array of Lists? Is that really necessary? Why not a List of Lists? And if it gets too complicated (a List of List of Map of List to…), use custom data types. This really makes the code much more readable.
And as an unrelated side note: You should write
List<Object>[] arrayOfList. The brackets are part of the type, not the variable.