473,395 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

index out of bound error

Expand|Select|Wrap|Line Numbers
  1.  
  2. public class settasks extends BLTHAdapter {
  3.      String subroleArr[];
  4.      static int i=0;
  5.      static int j;
  6.     public void handleSetSubject(BLTHContext ctx) throws Exception 
  7.     {
  8.     try{
  9.                         ..... some code   
  10.     for(j=0;j<v.size();j++,i++)
  11.     {    
  12.  
  13.         subroleArr[i]=some string
  14.        getsubroleArr(subroleArr[i],ctx);               
  15.  
  16.     }
  17.  
  18.     adminrole.setRoleDescription(subroleArr[0]);
  19. }
  20. catch(Exception e)
  21.     {
  22.     throw e;
  23.  
  24.     }
  25. }
  26. public void getsubroleArr(String v,BLTHContext ctx1)throws Exception
  27. {
  28. ..some code    
  29. while(some condition )         
  30.  {
  31.  
  32. i++;
  33. subroleArr[i]=some string
  34. getsubroleArr(subroleArr[i],ctx1); //function called recursively
  35.  
  36. }
  37. }        
  38.  
  39.         }
  40.  
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
Jun 15 '08 #1
3 1767
BigDaddyLH
1,216 Expert 1GB
I have no idea what your code is supposed do, what this immediately caught my eye:
Expand|Select|Wrap|Line Numbers
  1. static int i=0;
  2. static int j;
Static loop variables? In all my years of programming I've never seen that attempted. Could this be your error?
Jun 16 '08 #2
r035198x
13,262 8TB
What did you initialize subroleArr[]'s length to be?
Jun 16 '08 #3
JosAH
11,448 Expert 8TB
What did you initialize subroleArr[]'s length to be?
I don't think that matters much because that code shows that the index variable 'i'
is only incremented and never reset to a sensible value, so once 'i' will be larger
than the maximum array index. (ignoring an array having Integer.MAX_VALUE
elements)

kind regards,

Jos
Jun 16 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Uwe Mayer | last post by:
Hi, a class of mine should support the list interface and implements the __len__ and __getitem__ methods. Now when I ask for an unbounded slice: >>> len( myObj ) my __getitem__(self, y)...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
2
by: martin | last post by:
Hi, I have a dropdown control tha is rendered with the follwoing HTML <select name="FirstStep:CmbTargetGroup" id="FirstStep_CmbTargetGroup" style="width:152px;"> <option...
1
by: Ashutosh Bhalerao | last post by:
Hi all, I have bound an Arraylist of Objects to a repeater. All the items from the Object display fine on the screen. Now I need the current index being bound inside the <ItemTemplate>...
2
by: hari | last post by:
Anyone have a link to solve this one? I am using the SqlData class in an asp.net page. The class fills a data grid which contains a column to render more data to a string builder class. The index of...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
5
by: questions? | last post by:
I want to do list index function. >>> y= >>> y >>> y.index Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: unsubscriptable object It works with y=. Anyone has...
14
by: oLgAa25 | last post by:
Hello all, I am back I have this question everything compiles fine, but I just need to check for an index that is more than the array size. Although it says out of bound, but it is still...
13
by: venkatesh | last post by:
hai I need to know about array out of bound error which is thought by our lecturer .she thought that when u gross the intialially specified size it will show that error,but when I am working on...
85
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but it doesn't tell you what the range and the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.