Re: Strange things with java...
- From: Raghav <raghavendrav@xxxxxxxxx>
- Date: 11 May 2007 11:18:28 -0700
On May 11, 10:51 pm, Roberto Nicastro <robnicas...@xxxxxxxxx> wrote:
Hi all,
i have this piece of code
Suppose that lstA is List of 3 Objects
List<Object> lstA = ...something;
List<Object> lstB = lstA;
...
[block A] //this is a block of code
...
Inside block A i remove one item from lstA, so lstA become a List of 2
Objects. Inside block A i never touch lstB.
Why at the end of block A also lstB is with 2 elements? How is this
possible?
Thanks in advance
R
Actually here you have got one list in memory and 2 references to
that. So when u modify the list, it is reflected in either of
references pointing to that List.
HTH.
.
- References:
- Strange things with java...
- From: Roberto Nicastro
- Strange things with java...
- Prev by Date: Re: Strange things with java...
- Next by Date: Re: Still looking for a Job?
- Previous by thread: Re: Strange things with java...
- Next by thread: Re: Strange things with java...
- Index(es):