The following code unexpectatly throws the error shown below.
public static Long[] factorize() {
final ArrayList<Long> returnValue = new ArrayList<>();
return (Long[]) returnValue.toArray();
}
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Long;
at primes2019.Factorization.factorize(Factorization.java:69)
at primes2019.Factorization.main(Factorization.java:13)