I have the following class
class Item {
var name: String = ""
constructor(n: String) {
name = n
}
}
On my main activity I have declared this:
var list: ArrayList<Object> = ArrayList<Object>()
When I try to do this
list.add(Item("Hey friend"))
The compiler complains about type mismatch (Object -> Item) which is obviously true but since Item is also an Object, shouldn't this be fine? I'm pretty sure you can do this in Java, whats the alternative?
I need the list to be of type object because I have to store different stuff in there, so changing it is not an option.