I have two questions, actaully…
First off, Why cant I do this:
List<Object> object = new List<Object>();
And second, I have a method that returns a List<?>, how would I turn that into a List<Object>, would I be able to simply cast it?
Thank you!
You can’t do this because
Listis an interface, and interfaces cannot be instantiated. Only (concrete) classes can be. Examples of concrete classes implementingListincludeArrayList,LinkedListetc.Here is how one would create an instance of
ArrayList:Show us the relevant code and I’ll update the answer.