Suppose I insert 5 strings in an ArrayList. Will the order of insertion and retrieval from the ArrayList be the same?
Suppose I insert 5 strings in an ArrayList . Will the order of insertion
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, ArrayList is an ordered collection and it maintains the insertion order.
Check the code below and run it:
Produces the following output:
For detailed information, please refer to documentation:
List (Java Platform SE7)