Try to write:
List<Object> list;
@SuppressWarnings("unchecked")
list = (List<Object>) new Object();
It will fail on the 3rd line, on the word list
, with the following:
list cannot be resolved to a type
I understand that it is related to how annotations work. Anybody knows the reasoning behind this?
EDIT: thanks for the fast answer. I knew it'd work if the assignment was made also a declaration, anyway.