我是靠谱客的博主 喜悦小懒猪,这篇文章主要介绍java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer;,现在分享给大家,希望可以做个参考。
报这个错是因为集合转换数组时出错
错误写法:
List userIdList = new ArrayList();
Integer[] array = (Integer[]) userIdList.toArray();
正确转换方法:
List userIdList = new ArrayList();
Integer[] array = (Integer[]) userIdList.toArray(new Integer[userIdList.size()]);
最后
以上就是喜悦小懒猪最近收集整理的关于java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer;的全部内容,更多相关java.lang.ClassCastException:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复