gpt4 book ai didi

java - ArrayList 插入(java)

转载 作者:行者123 更新时间:2023-11-29 06:00:14 26 4
gpt4 key购买 nike

我应该如何将 double 值插入到 ArrayList 的特定部分?例如,我们有一个包含 10 个 double 值的 ArrayList,每个值为 0 我们希望第六位为 10,我们应该怎么做?

最佳答案

使用ArrayList.set()方法:

public E set(int index,             E element)Replaces the element at the specified position in this listwith the specified element. 

For example:

list.set(5, new Double(10));

关于java - ArrayList<Double> 插入(java),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10430186/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com