Why am I getting this error for my code on the problem The Next Palindrome (http://www.codechef.com/problems/PALIN)
import java.io.*;
public class Main
{
public static void main(String[] args)throws IOException
{
int i;
long k;
int j;
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("Input:");
i=Integer.parseInt(br.readLine());
long arr[]=new long[i];
for(j=0;j<i;j++)
{
arr[j]=Long.parseLong(br.readLine());
}
System.out.println("Output:");
for(j=0;j<i;j++)
{
System.out.println(Palindrome(arr[j]));
}
}
public static long Palindrome(long k)
{
long n=k+1;
while(true)
{
if(pal(n))
return n;
n=n+1;
}
}
public static boolean pal(long n)
{
long n2=n;
long sum=0;
long dig;
while(n2>0)
{
sum=sum*10;
dig=n2%10;
sum+=dig;
n2=n2/10;
}
if(sum==n)
return true ;
else
return false;
}
}