java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer;
生活随笔
收集整理的這篇文章主要介紹了
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;的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: git中的删除命令操作
- 下一篇: git提交代码,合并同步分支