int n = myarray.length;
What is the Big O of this statement?
An Array is a reference type, which contains its .length as a stored value. We can tell that .length is a stored value rather than a method because it has no parentheses after it.
Rule: any stored .field of a reference type can be accessed in O(1) time.
Prev Next Page+10