Arraylist没有删除对象 [英] Arraylist without remove object

查看:89
本文介绍了Arraylist没有删除对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Arraylist ,例如

ArrayList<SomeType> newObjectList = new ArrayList<>();

我想使用 Arraylist中的对象不使用方法删除
我不想从列表中删除对象,只是为了引用它并使用它的方法。

I want to use an object from the Arraylist without using the method remove. I don't want to remove the object from the list, just to refer to it and use its methods.

我该怎么做?谢谢。

推荐答案

使用方法 newObjectList.get(index)代替

文档

这篇关于Arraylist没有删除对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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