Java List. Size () method: returns the number of elements in the list
•
Java
size()
Example
public static void main(String[] args){ List<String>list = new ArrayList<String>(); list.add("保护环境"); //向列表中添加数据 list.add("爱护地球"); //向列表中添加数据 list.add("从我做起"); //向列表中添加数据 int listSize = list.size(); //获取列表中元素的个数 Sy@R_404_2354@.out.println("列表中元素的个数:"+listSize); }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码