Casting
//Assuming that there is some bethod
public Weapon maxWeapon(Weapon firstWeapon, Weapon secondWeapon);
//We can cast to a subclass if we know that the resultant weapon will have
//the type we want.
Polearm maxPole = (Polearm) maxWeapon(new Polearm(13), new Polearm(34));Polearm maxPole = (Polearm) maxWeapon(new Claymore(445), new Catalyst(45));Last updated