posted 19 years ago
hai rama,
as far as ur program is concerned,u r trying to access a static method.
in general,static methods take the reference and not objects & so u get the result (as mentioned in ur 1st code).
----------------------------------------------------------------------------
I understand the static method printing. But not the instance variable str.
----------------------------------------------------------
instance variables are similar in behaviour to static methods,they too refer only the reference and not the objects.
hence according to ur code(both 1st & 2nd ),u r creating the reference for the class & trying to print the str(instance variable)from that class,since instance variables refer to references & not objects,it takes the value os str in that particular class which it refers to.
if still not clear,plz reply
regards
-sakthi
" Don't be afraid of pressure. Remember that pressure is what turns a lump of coal into a diamond... " <br /> <br />Thanks & Regards...<br />Sakthi<br />SCJP1.4, OCA