Okay. What would be the equivalent for a string array? In this example? "Integer" is just a word? I mean shouldn't it be declared first someone else, like a type of some kind? So we could use
As long as "Taco" is typed somewhere I'm guessing?
Joined: Jan 28, 2012
OK so some more searching led me to something about a "wrapper" and the fact that String is in fact already a wrapper class. So why won't this work? I guess it's got nothing to do with primitives? My bad.
The solution was I needed to include the correct libraries such as
Regarding the original question, the one about using Arrays.asList() on a primitive array int:
Unfortunately, I don't think that does what you think it does. As an experiment, try to get the first element of the List you've created with Arrays.asList(), and print it out. What is it? Is it what you expected? I think it will not be. This is an unfortunate side effect of having too many overloads.
For comparison, Google's Guava library offers Ints.asList(int...), which I think does exactly what you want. Google does a good job of finding and plugging holes like this in the APIs.
Did you read the documentation for Arrays#asList(T...). The writers of the documentation expect you to know that “T” is a generic type and generics only applies to reference types, not primitives. You will have no end of difficulty getting your Taco array past the compiler; it expects you to know that boxing conversions only apply to the 8 wrapper types and the 8 primitives. Note there is un-boxing as well; you can box any primitive type and unbox any wrapper object pointed to by a reference, but not null.
There are several different meanings for the term “wrapper class”; I think you are using it here to mean one of the 8 classes which correspond to the 8 primitive types. You can’t call String a wrapper class, then. It doesn’lt “wrap” anything. I don’t think String ever falls within any of the meanings of wrapper class.