jaspreet manchinda wrote:what do casting actually do
It changes the way the language 'sees' an object, generally from a less specific to a more specfic type.
and when can we use object type casting
As Campbell said: as little as possible. With generics you can almost eliminate the need to do it at all.
The biggest remaining exception is in
equals() methods:
Because the method takes an
Object, it's usually necessary to cast it to the type being compared with, once you've established that it is, in fact, the one you want. So, for example:
HIH
Winston