Java code for a Coursera class