public String multiply(String num1, String num2) {
        int l1 = num1.length();
        int l2 = num2.length();
        char [] res = new char[l1+l2];
        Arrays.fill(res, '0');

        for(int i = l2 - 1; i >= 0; --i){
            int carry = 0;
            int n2 = num2.charAt(i) - '0';
            int j = l1 - 1;
            for(; j >= 0 ;--j){
                int n1 = num1.charAt(j) - '0';
                // not only add carry but also add the computed result in the corresponding position
                int s = n1 * n2 + carry + res[i+j+1] - '0'; // key statement
                int r = s % 10;
                res[i+j+1] = (char)(r + '0');
                carry = s / 10;
            }
            res[i+j+1] = (char)(carry + '0');
        }

        int b = 0;
        for(; b < l1+l2; ++b){
            if(res[b] != '0'){
                break;
            }
        }
        if(b == l1 + l2){
            return "0";
        }
        return new String(Arrays.copyOfRange(res, b, l1+l2));
    }