Java portion of module 2 code