adding java solution