By declaring other
as final
, it means that you can not change the value once it has been set.
The reason you're casting to a Person
object is because, the parameter of is type Object
. That means you can get all of the methods in the Object
class. By casting it to Person
, you can access all of the methods in the Person
class. The same functionality could be achieved by:
((Person)obj).personMethod();