Is it possible to save a Type in a variable,
in order to instantiate a List of this type?
//something like that
Type type = Boolean;
List<type> list = new List<type>();
list.add(true);
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.
For the first requirement, you are looking for
Class:However, I don’t think the seconds requirement is feasible, since generic types only exist at compile time:
You can, however, work with
List<Object>. It will acceptBooleanobjects. Whether this will buy you anything untlimately depends on your use case.