Say I have the following two empty lists
List<String> obj1 = new ArrayList<String>();
List< Integer> obj2 = new ArrayList<Integer>();
without foreknowledge, how can I tell which is of type String
and which is of type Integer
? (Please, never mind why I need this info).
Here I can no longer do
if (!list.isEmpty() && list.get(0) instanceof String)
as the list is empty.