Added Java solution