1

When I declared final arraylist(), then can I perform insert,search and update operation in that arraylist or not.

1
  • 2
    What programming language are you using? Commented Nov 4, 2009 at 7:50

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

Comments

3

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;

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.