class Entity { public void collide(Entity other) { System.out.println("Generic version!"); } } class Ship extends Entity { public void collide(Ship other) { System.out.println("Ship collides with Ship."); } public void collide(Asteroid other) { System.out.println("Ship collides with Asteroid."); } } class Asteroid extends Entity { public void collide(Ship other) { System.out.println("Asteroid collides with Ship."); } public void collide(Asteroid other) { System.out.println("Asteroid collides with Asteroid."); } } public class Dispatch { public static void main(String args[]) { Entity s = new Ship(); Entity a = new Asteroid(); s.collide(a); } }