Forum : run time error
Brief description  about Online courses   join in Online courses
View nishant  gaurav 's Profile

run time error

class branch
{
public static void main(String[] args)
{
int[] a={12,34,35,42,9,76,31,54,99,150};
int i;
boolean gotit=false;
for(i=0;i<a.length;i )
{
for(int j=2;j<a[i];j ){
if(a[i]%j!=0)
{
gotit=true;
break;
}
}

}
if(gotit)
{
System.out.println("found the prime no is" a[i] "at index" i);
}
else
{
System.out.println("no number is prime in given array");
}
}
}
i am getting runtime error as arrayindexoutofbound
Asked by nishant gaurav | May 5, 2010 |  Reply now
Replies (3)
View bhushan hanumant shinde 's Profile
LOLz @Padmini.
@nishant :u r mistaking at ur syntax only.
see at "SOPLn" statement and "for" loop too...
Jul 17, 2010
View padmini manjunath 's Profile
is that only 1 error you are getting?Because in this code in for loop i and j increment is not found which gives error and so on... I found nearly 34 error....
May 9, 2010
View siji jimmy 's Profile
because the i value is 10 once you get out of the for loop and the system cant found a value at a[10] which is out of boundry.
May 5, 2010