Java Version of Lab3