Because ArrayList is a basically a class means reference type and when we pass reference type as a parameter then copy of reference gets passed to the method parameter. Because of which we get two variables pointing to the same object in memory. Any change to that variable in called method get reflected in calling method.
Manish PandeyRank #4,053 · 369 pointsPosted Apr 11, 2016, 1:11 AM EDT
a basically a class means reference type and when we
pass reference type as a parameter then copy of reference
gets passed to the method parameter. Because of which
we get two variables pointing to the same object in
memory. Any change to that variable in called method get
reflected in calling method.
Answered By - Manoj Kulkarni