add java solution for MthToLast