codes from Dan Friedman's A Little java,A few Pattrens