Hi Rachil,
Here you go...
1- There is one class variable s, assigned value "Instance";
2- Inside main() you created Test4 object and assigned it to t reference variable;
3- You reassigned class variable s = "New Instance";
4- Now local variable whose name is same as class variable, gets birth
and you assign it a value "Local".
5- Because you have now local variable s, what you pass to method() is local
variable s. (Test14.s == "static variable s", t.s = "static variable s" and
only s = "local variable s" and t=null then t.s = still static variable s)
6- In the method() effect of adding "Add" to passed
String will have local
effect (passed by value concept).
7- In the main() method now you would have got...
s = "Local"
t.s = "New Instance"
Does this help you clear your doubt?
Regards,
cmbhatt
[ April 09, 2007: Message edited by: Chandra Bhatt ]