我的代碼定義ArrayList為:ArrayList<Float> dummyArray = new ArrayList();和一個(gè)float變量定義為:float smoothedValue;代碼執(zhí)行如下: if(x==1 && dummyArray.size()>1) //x is an int{smoothedValue = dummyArray.get(dummyArray.size()-1); //Error here}我收到以下錯(cuò)誤:java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Float變量在同一個(gè)方法(類中的私有方法)內(nèi)定義,并且都是浮點(diǎn)型( 的元素ArrayList也是浮點(diǎn)型)。為什么我會(huì)收到此錯(cuò)誤?我做錯(cuò)了什么嗎?
當(dāng)兩個(gè)變量在 android studio 中都是浮點(diǎn)數(shù)時(shí) ClassCastException
HUH函數(shù)
2023-10-13 09:50:34
