added java solution for problem C