如何在ArrayList中的某个位置更新元素? [英] How do I update the element at a certain position in an ArrayList?
本文介绍了如何在ArrayList中的某个位置更新元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有10个String
中的一个ArrayList
.如何用另一个String
值更新索引5
?
I have one ArrayList
of 10 String
s. How do I update the index 5
with another String
value?
推荐答案
让arrList
成为ArrayList
,而newValue
成为新的String
,然后执行:
Let arrList
be the ArrayList
and newValue
the new String
, then just do:
arrList.set(5, newValue);
这可以在Java api参考此处中找到.
This can be found in the java api reference here.
这篇关于如何在ArrayList中的某个位置更新元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文