Inside TaxPayer, we want to use the derived class P directly in
the extortCash() method. However, the only way of getting an
instance without compiler warnings is to pass it in from the
subclass. We can solve this issue with a factory method
called getDetailedType() that returns the subclass.
The beauty of using generics here is that EmployeeTaxStrategy
does not need to downcast anymore.
A computer scientist working for a Tokyo-based, technical university called "Tokyo Institute of Technology." I bookmark research related pages and also pages related to my private life such as cooking recipes, restaurants, amusement events, etc.