So I'm trying to find the largest product of 2 3-digit numbers that is a palindrome. Here's my code:
class project_euler4 {
    public static int largest_palindrome = 0;
    public static boolean isPalindrome(int number) {
        String original = Integer.toString(number);
        String reversed = new StringBuffer(original).reverse().toString();
        return (original == reversed) ? true : false;
    }
    public static void main(String[] args) {
        for (int i = 100; i < 1000; i++) {
            for (int j = 100; j < 1000; j++) {
                int candidate = i * j;
                if (isPalindrome(candidate) && candidate > largest_palindrome) {
                    largest_palindrome = candidate;
                }
            }
        }
        System.out.println("The largest palindrome made from the product of 2 3-digit numbers is " + largest_palindrome);
    }
}
When I compile and run, I get:
The largest palindrome made from the product of 2 3-digit numbers is 0
So for some reason, my largest_palindrome variable isn't getting updated when a product is a palindrome. I suspect it has something to do with my isPalindrome() function, but am not sure.
Any ideas?
Thanks for the help, Mariogs
 
    