Java ArrayList replace at specific index

后端 未结 5 2157
说谎
说谎 2020-11-27 13:36

I need help with this java please. I created an ArrayList of bulbs, and I\'m trying to replace a bulb at specific index with another bulb. So with the following heading, how

5条回答
  •  清歌不尽
    2020-11-27 14:23

    public void setItem(List dataEntity, Item item) {
        int itemIndex = dataEntity.indexOf(item);
        if (itemIndex != -1) {
            dataEntity.set(itemIndex, item);
        }
    }
    

提交回复
热议问题