Example Java code to show how various design patterns work.