I put the doubt part in the comment of this following code assigning them number 1>>,2>>,3>>.. please anybody clear it... here is the code
Add code tags. CR[/edit]
[ September 05, 2008: Message edited by: Campbell Ritchie ]
1>> It says can not find symbol d.CollarSize() why ??;
Because a dog object doesn't have a method that returns the collar size -- as explained by the error message.
//2>> here it prints Collar@12b6551(which is address) why so why not content state;
Because the printing mechanism will convert it to a string before printing it, and the default toString() method gives the type and the indentity hashcode. How do you expect Java to know what valid "content state" is, when it is your code? If you want it, you have to override the toString() method.
d.getCollar().getCollarSize();//3>> why the order of invocation is like this way why not the reverse way...this is really not understood properly;
Can you explain why it is "really not understood properly"? It makes perfect sense to me. You are calling the collar() method on the dog object. This method returns an collar object, which you call the collar size method on. Maybe it is better understood, if you add parens....