ok now i am even more confused. Thank you for the answers.
let me respond one by one.
1>Shay..
lets say i declare ArrayList<Dog> ar=new ArrayList<Dog>(). i can add ar.add(new Poodle()) where Poodle extends Dog cause Poodle is a Dog , right?So going by the same logic,let me explain my confusion.
i have
class Sport<Object>
{
ArrayList<Object> ar;
Sport(ArrayList<Object> ar)
{
this.ar=ar;
}
}
so if i instantiate Sport as Sport sp=new Sport(arrayList); where arrayList contains string elements, this is wrong??? even though i have declared arrayList as ArrayList<Object> arrayList= new ArrayList<Object>(); and added string elements to it.
If i am wrong in my above understanding please do correct me.
2>Henry...
class Sport<Object>
{
} this is wrong?? compiler would not recognize this as adding any object?please explain.
and by bounded types is this what you are suggesting
class Sport<T extends Object>
{
}
??
Please do help, cause the more i dwelve into generics the more confused i seem to get.
I apologize if the questions are outright stupid.
