solved problem 002 in java

Signed-off-by: Arvind Chembarpu <achembarpu@gmail.com>