why we make obj.getClass().getName() call? I understand that this will return the name of the class, but my question is why is the syntex the way it is, i mean getClass method calls getName method. where this type of call is used ?
If you have an object and do a getClass() on it, it will return another object of the Class class. If you look in the API for Class you will see that it has a method getName() that returns a String representation of the class. you COULD have split that syntax up into 2 statements: Class c = obj.getClass(); String s = c.getName(); But it is more streamlined to weld it all together. String s = obj.getClass().getName();
"JavaRanch, where the deer and the Certified play" - David O'Meara
Look at how JavaBeans work. All properties are encapsulated in getXX and setXX methods. Whenever you see a getSomething() method, you know it will simply give you the Something property on the object. Any calls from there, eg xx.getSomething().runAway("fast"); are methods on the object that getSomething() gave you.