Steve Luke wrote:Lists only accept Objects, and int is not an Object, so it can't go into the List. Because of this the Arrays.asList(T source ...) method misunderstands what you are sending it (it assumes you are using varargs to create a List with 1 Object in it, that Object being an int).
You need to use the Integer wrapper Object instead of the primitive int:
Greg Charles wrote:If you have trouble with the abstract idea of super classes and sub classes, try to think of it in real world terms. Like I have a Pet, which is a Dog, which is a GreatDane. You have a Pet, which is a Cat, which is a Siamese. Now, I can say you have a pet, or I can say you have a cat. You can say I have a pet, or a dog. I can't say you have a dog, even though it's a pet.
Now let's say that someone else has another kind of Pet, which is just general, no particular species. (The real world example sort of breaks down here, but try to follow along.) We can call it a pet, but we can't call it a dog or a cat, since those are specific kind of pets.
You are essentially doing that in your program. You are saying Hector is a Beta. (And I thought he was a Trojan!) However you are creating a general Beta, and trying to call it a Hector. That's just like calling that guy's Pet a Dog. Some Betas are Hectors, just as some Pets are Dogs, but not all of them.
So what I was doing in
was that trying to downcast the generalised class Beta's reference.