Java- Why is’nt my code producin the correct results?

I was solving problem 4 of ProjectEuler and couldn’t get it right. This is my code.

public static long reverseNumber(long number){
    long reversed = 0;

    while(number != 0) {
        long digit = number % 10;
        reversed = reversed * 10 + digit;
        number /= 10;
    }
        return reversed;
}

long sum,finalSum=1,revSum;
    for (int i=100;i<1000;i++){
    for (int j=100;j<1000;j++){               
        sum=i*j;
        revSum=reverseNumber(sum);
            if (sum==revSum){
            finalSum=sum;
            }

        }
    }
    System.out.println(finalSum);

This was some code I found online and it worked perfectly.

int maxPalin = -1;
    for (int i = 100; i < 1000; i++) {
        for (int j = 100; j < 1000; j++) {
        int prod = i * j;
        if (prod > maxPalin){
                if (reverseNumber(prod)>maxPalin) {
                    maxPalin = prod;
                }
        }
        }
    }
System.out.println(Integer.toString(maxPalin));

But whats wrong with mine?