获取特定的ArrayList项目 [英] Get specific ArrayList item

查看:77
本文介绍了获取特定的ArrayList项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public static ArrayList mainList = someList;

我怎样才能从这个特定的项目的ArrayList mainList [3]

推荐答案

正如许多已经告诉过你:

As many have already told you:

mainList.get(3);

请务必查看 ArrayList中的Javadoc

此外,要小心数组索引:在Java中,第一个元素是指数 0 。所以,如果你想获得的第三个元素,你的解决方案将是 mainList.get(2);

Also, be careful with the arrays indices: in Java, the first element is at index 0. So if you are trying to get the third element, your solution would be mainList.get(2);

这篇关于获取特定的ArrayList项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆