will be helpful for those in need I think you can only cast the Object next = ... object into the type java.util.Arrays$ArrayList, but because it is a private static class, it is better to cast it to java.util.List class. Like:
List<?> result = lib.get();
Iterator<?> iterator = result.iterator();
Object next = iterator.next();
List<Integer> list = (List<Integer>) next;
wish helps you What you are trying to do cannot be achieved by one simple cast. This has to do with type erasure during compilation of Java code. You can do one of two things: Cast and accept the unchecked warning (you can suppress it by adding @SuppressWarning on the method). Only do this if you are sure that the Object is actual of type List otherwise you will get ClassCastExceptions at runtime. Check the type of the variable against List and then iterate over it adding each entry to a new list of type T. You can then validate each entry in the original list against type T before adding it. (Not doing so will also result in the unchecked warning)
Java: Selenium: WebDriver: Unable to Parse a List<WebElement> Object; Get Error "cannot be cast to java.lang.