first part of java code DONE