I am making the program forthe largest palindrome made from the product of two 3-digit numbers. But program is giving product of 999*999=998001 Can anyone tell what's wrong in this code?
Program-
public class abc {
public static void main(String[] args)
{
int p=0,temp=0;
for(int i=100;i<=999;i++)
{
for(int j=100;j<=999;j++)
{
p=i*j;
StringBuilder sb=new StringBuilder(Integer.toString(p));
sb.reverse();
if((sb.toString()).equals(Integer.toString(p)) && p>temp)
{
temp=p;
}
}
}
System.out.println(temp);
}
}