Thankyou Preeti,
I guess I'm still confused about object creations in a program.
Pl look at the code below,
the output is : true,true,false,false
1)why is line 3 false? if "A"+"B" and c refer to the same object in memory, then a+b which evaluates to "AB" should refer to the same object, ??
2)are the expressions in println statement evaluated at run time?
3)As Vidya said, 'd=a+b' is evaluated at runtime and therefore a new instance of "AB" is created, so d and c references are not same. Is is not right that "A"+"B" in line1 should also create a new instance of "AB" at runtime and therefore "A"+"B" and c do not refer the same value.
Can someone PLEASE explain this ?
and can someone please guide to me links where I can read more about this topic?
Thankyou.
[ April 28, 2003: Message edited by: Sharda R Govindu ]