I have list having data like a, b, c, d, e, f, g, h, i if i want this list i would say getList(); which returns me a arraylist,i need only the value at开发者_如何学JAVA index 10 that is 'i' ,how would i do this ?
getList().get(8);
Have in mind that index is 0-based. So index 8
means the 9th
item.
Advice: always look at the javadoc, or open the autocomplete of your IDE, to see what methods does your object have. Most of them are named and documented in a way that it is explicitly known what they actually do.
For example, in your case, google for "ArrayList", open the first result (from java.sun.com), and look through the methods there.
I'd go with get().
BTW, you can find the complete Java API docs here. I'd highly recommend bookmarking it.
精彩评论