Is ArrayList an array or a list in java? what is the time complexity for the get operation, is it O(n) or O(1)?
Is ArrayList an array or a list in java? what is the time complexity
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.
An
ArrayListin Java is aListthat is backed by anarray.The
get(index)method is a constant time,O(1), operation.The code straight out of the Java library for
ArrayList.get(index):Basically, it just returns a value straight out of the backing array. (
RangeCheck(index)) is also constant time)