如何在ArrayList中的某个位置更新元素? [英] How do I update the element at a certain position in an ArrayList?

查看:1589
本文介绍了如何在ArrayList中的某个位置更新元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有10个String中的一个ArrayList.如何用另一个String值更新索引5?

I have one ArrayList of 10 Strings. 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屋!

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