Java Solution Added.