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;
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
報(bào)這個(gè)錯(cuò)是因?yàn)榧限D(zhuǎn)換數(shù)組時(shí)出錯(cuò)
錯(cuò)誤寫法:
List userIdList = new ArrayList(); Integer[] array = (Integer[]) userIdList.toArray();正確轉(zhuǎn)換方法:
List userIdList = new ArrayList(); Integer[] array = (Integer[]) userIdList.toArray(new Integer[userIdList.size()]);總結(jié)
以上是生活随笔為你收集整理的java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer;的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: git中的删除命令操作
- 下一篇: git提交代码,合并同步分支