最终数组列表声明
当我声明final arraylist()时,我是否可以在该arraylist中执行插入、搜索和更新操作。
When I declared final arraylist(), then can I perform insert,search and update operation in that arraylist or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Final表示指向arraylist的变量不能改变。但这并不意味着你不能调用该对象的任何方法,因此你可以对该对象执行插入、搜索和任何其他操作
Final means that the variable pointing to the arraylist can't change. But that does not mean that you can not call any method of the object, so you can perform insert, search and any other operation to the object
如果列表被声明为最终列表,如下所示:
没有什么可以阻止对列表的修改:
但是,以下情况是不可能的:
If a list is declared final as follows:
there's nothing to stop modifications to the list:
However, the following would not be possible:
如果您谈论的是 Java 的 ArrayList,那么,是的,您可以。 Final 意味着您无法更改变量引用的 ArrayList 实例。
If you're talking about Java's ArrayList, then, yes you can. Final means just that you can't change which ArrayList instance your variable refers to.