开发者

how to count number of items in an array android [closed]

开发者 https://www.devze.com 2023-03-29 10:43 出处:网络
This question is unlikely to help any future visitors; it 开发者_StackOverflow中文版is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation th
This question is unlikely to help any future visitors; it 开发者_StackOverflow中文版is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

How can I count the number of items in an array in android?

here is the code that dose not work

if (vehicleList.length = 1){
     //do something                  
                     }

can anyone help?


Use == for comparison..

if (vehicleList.length == 1){
     //do something                  
 }


You are trying to assign a value to vehiclelist.length. Use == instead which will compare the two values.


if vehicleList is an arrayList the try like this

if (vehicleList.size() == 1){
     //do something                  
}
0

精彩评论

暂无评论...
验证码 换一张
取 消