For an ArrayList, how does java compute the memory location of the object at a particular position in arraylist.
In above case, we can put any type of object in the ArrayList which might have different memory allocated based on the type of object. When I am trying to get an element, how is the actual memory location is obtained? Does it keep track of all the memory allocated for different types of objects or is there a standard memory size allocated for each object.
This has been discussed before but I couldn't find the earlier thread, so I'll repeat the answer.
In Java, you don't store objects - you store references to objects. Each reference has the same fixed size, although the size depends on the JVM implementation. Usually it's either 32 or 64 bits, although that's irrelevant.
The actual objects definitely can have different sizes, but they aren't stored in the array list, just references to them. They themselves are stored on the heap.