java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Long;

public class CategoryDTO {
    /**
     * {"categoryIds":[]}
     */
    private List categoryIds;

Long[] catIds = (Long[]) categoryDTO.getCategoryIds().toArray();

修改为

 Long[] catIds = categoryDTO.getCategoryIds().stream().toArray(Long[]::new);

使用 java8 实现List到Array的转换_tao_wei162的博客-CSDN博客开发中需要调用第三方的库,有些 API 的入参要求是 double[] 数组,程序根据用户在页面的输入,计算出一个 double[] 作为返回值的结果,然后调用这个 API。往往无法预先知道这个 double[] 数组的大小,就不能直接定义一个 double[] 的变量,只能借助 List,先将数据放入 List, 再转换为 double[] 数组。这个很简单,一个 for 循环就搞定了,...https://blog.csdn.net/tao_wei162/article/details/84916585

你可能感兴趣的:(大数据)