java 如何计算数组中的项目数android

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7119275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 18:42:17  来源:igfitidea点击:

how to count number of items in an array android

javaandroidarrays

提问by user902080

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

如何计算android中数组中的项目数?

here is the code that dose not work

这是不起作用的代码

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

can anyone help?

有人可以帮忙吗?

回答by Kartik Domadiya

Use == for comparison..

使用 == 进行比较..

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

回答by Adam Arold

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

您正在尝试为 Vehiclelist.length 分配一个值。使用==它来比较两个值。

回答by jainal

if vehicleList is an arrayListthe try like this

如果 VehicleList 是这样arrayList的尝试

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