Half of java solution