When I declared final arraylist(), then can I perform insert,search and update operatio开发者_开发问答n in that arraylist or not.
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:
public final List myList = new ArrayList();
there's nothing to stop modifications to the list:
myList.add("value");
However, the following would not be possible:
myList = new ArrayList();
myList = someOtherList;
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.
精彩评论