Strange situation - below is the code:
ArrayList listArr = new ArrayList<>(); Object[] obj = new Object[]{\"str\", listArr}; String st
The compiler complains
ArrayList list = (ArrayList) obj[1]
because a cast is a runtime check. So at runtime your ArrayList could be a ArrayList, because the type of obj is unknown.
ArrayList