title: Why this program is giving wrong output for palindrome?
body: <p>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?</p>
  
  <p>Program-</p>
  
  <pre><code>public class abc {
      public static void main(String[] args) 
      {
          int p=0,temp=0;
  
          for(int i=100;i&lt;=999;i++)
          {
              for(int j=100;j&lt;=999;j++)
              {
                  p=i*j;
                  StringBuilder sb=new StringBuilder(Integer.toString(p));
  
                  sb.reverse();
                  if((sb.toString()).equals(Integer.toString(p))  &amp;&amp; p&gt;temp)
                  {
                      temp=p;
                  }
              }
          }       
          System.out.println(temp);
      }
  }
  </code></pre>