I've two question, They may be silly questions but it got me confused now.
QUESTION 1:
I've this code:
private List<Car> carList;
public void setData(List<Object> list)
{
this.carListist = list;
}
But on this.carList = list
I get a compiling error: incompatible types, required: List<Car> but found List<Object>
My question is, why this error? Isn't List a list of objects type Car? So why doesn't it accept an Object there?
QUESTION 2: I change the above code to the following and the error goes away:
private List<Object> carList;
public void setData(List<Object> list)
{
this.carListist = list;
}
public Object getValueAt(int row, int column) {
Car car = carList.get(row); //Compiling error here
switch(column)
{
(...)
}
(..)
Ther compiling error (signed in the code comment) is incompatible types, required Car but found Object
What I don't understand is, now list is defined as an object list. Car is an object. Why car, as being an object, is not accepted?
Anyway to fix this for both question 1 and 2?