When I go to run this I get the error:
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer; at Main.main(Main.java:30)
public class Main 
{ 
    private interface Function<R, D> 
    { 
        public R apply(D parameter);
    }
    public static void main(String[] args) 
    {           
        // Example 1
        Function<Integer, Integer> function = new CalculateSuccessor();
        Integer[] integerArray = {1, 3, 4, 2, 5};
        PrintArray(map(function, integerArray)); // map returns {2, 4, 5, 3, 6}  <--- line 30
    }
    @SuppressWarnings({"unchecked"})
    public static <R, D> R[] map(Function<R, D> function, D[] array)
    {
        R[] results = (R[]) new Object[array.length];
        // Iterate through the source array, apply the given function, and record results
        for (int i = 0; i < array.length; i++)
        {
            results[i] = (R)function.apply(array[i]);
        }
        return results;  
    }
    public static <T> void PrintArray(T[] array)
    {
        for (T element : array)
        {
            System.out.println(element.toString());
        }   
    } 
}
 
     
     
    