I have a class Message and a list of message : List<Message> messages
I cannot do List<Object> objects = messages; I know that.
But I can do this without compilation errors :
Object object = messages;
List<Object> myList = (List<Object>) object;
myList.add(new Object());
Then my messages list can contain any object and not just Message objects. Why is that ?
List<Message>to aList<Object>, it's still the same object.-Werrorto make the compiler treat them as errors.)