I'm working my way through Project Euler, and on problem 4 my palindrome code isn't working. Specifically, it returns 998001 (999*999) as if it were a palindrome.
The code to check the palindrome works, but it keeps looping and replacing the max value despite it not being a palindrome. What am I missing?
Thanks for your help
public int palindromeNumber()
{
    int max=0;
    for(int x = 100; x<1000; x++)
    {
        for(int y = 100; y<1000; y++)
        {
            int z = x*y;
            StringBuilder num = new StringBuilder(Integer.toString(z));
            StringBuilder rev = num.reverse();
            if(num==rev)
            {
                max=z;
            }
        }
    }
    return max;
}
 
     
     
     
    