-
-
public class settasks extends BLTHAdapter {
-
String subroleArr[];
-
static int i=0;
-
static int j;
-
public void handleSetSubject(BLTHContext ctx) throws Exception
-
{
-
try{
-
..... some code
-
for(j=0;j<v.size();j++,i++)
-
{
-
-
subroleArr[i]=some string
-
getsubroleArr(subroleArr[i],ctx);
-
-
}
-
-
adminrole.setRoleDescription(subroleArr[0]);
-
}
-
catch(Exception e)
-
{
-
throw e;
-
-
}
-
}
-
public void getsubroleArr(String v,BLTHContext ctx1)throws Exception
-
{
-
..some code
-
while(some condition )
-
{
-
-
i++;
-
subroleArr[i]=some string
-
getsubroleArr(subroleArr[i],ctx1); //function called recursively
-
-
}
-
}
-
-
}
-
The above code is wrtitten using API's .I have written a recursive function getsubrolArr() , this recursive fucntion is storing values in a array. For counter of the array i have used a static variable i.
But when I am trying to increment i in the function getsubrole. I am getting "java.lang.ArrayIndexOutOfBoundsException: 2"
Is there any thing wrong in the incrementing i in the above code.
Any pointers will be very helpful