Lets say there is an array that contains a series of objects,
Object[] list;
and a method designed to iterate through this array, for example
public boolean contains(Object e)
{
for(Object e_:list)
if(e_.equals(e))
return true;
return false;
}
What I'm confused about is how the for loop iterates the array. When iterating, does it assign e_ to the same memory location as list[index] or is e_ a new object cloned from list[index], because what I want to do is use == instead of equals() so that I can specifically call the object and not risk it being equal() to another. I understand I could override equals() and make it final to prevent inheritance from being an issue, but I would like to understand how iteration works inside of an enhanced for loop.