cancel
Showing results for 
Search instead for 
Did you mean: 

getting index out of bounds: index =13 size =5

Former Member
0 Kudos

Hi ,

I am getting Index out of bounds exception.

Please help.

Thanking You.

Regards,

Reinuka Paul.

Accepted Solutions (0)

Answers (8)

Answers (8)

p330068
Active Contributor
0 Kudos

Hi Reinuka Paul

To Avoid Index out of bounds exception try to use the code inside Try/Catch block with


int node_size = wdContext.node<Node Name>().size();

if(node_size > 0)
{
       // Write your code here      
}

This will resolved your issue with index out of bounds. Check NWDS Error log <Windows : Show view : Others : PDE Runtime : Error Logs > for more details

Hope it will helps

Regards, Arun Jaiswal

Former Member
0 Kudos

Post the complete stacktrace and the code that causes the exception.

Former Member
0 Kudos

Hi Reinuka,

Are you trying to access a node instance that does not exist ?

Like suppose u have a 0..n cardinality node under Context named AAA and an attribute inside it named bbb.

if u are using any code like :

wdContext.nodeAAA().getAAAElementAt(i).getbbb() ;

where 'i' is a loop iterator.

Suppose if the value of i is 13 but the size of node AAA is 5, the its likely that you will get this error.

Regards,

Sayan Ghosh

Former Member
0 Kudos

Hi,

To avoid index out of bound error always check whether the node has values and then proceed with the looping statement.

if(!wdcontext.nodetable().isEmpty)
{
  int table_size = wdcontext.nodetable().size();
  for(int i=0;i<size;i++)
  {
     ------
  }
}

Regards,

Bala Baskaran.S

Former Member
0 Kudos

Hi,

this will appear if you trying to access the data of node whose size is less than the size of your parameter in the loop.

Regards,

Govindu

Former Member
0 Kudos

Hi,

It seems you are iterating the context node or any string array for more than its size.

As per the message its trying to get the value of index 13 but the actual no. of elements in the context node is 5 only or String array size is 5.

Share the code for more clarity.

Regards

Deepak

Former Member
0 Kudos

Hi,

Index Out of Bound Exception Occurs when we try to access an element of beyond the storage capacity of the index. check the size of your total records with the index you are passing. Your index should be less or equals than the total size.

Regards

Suresh Bachimanchi

former_member185879
Active Contributor
0 Kudos

Hello Paul,

Where you are getting index Out of Bound Exception? Explain bit more on when and where it is coming.

If it is coming while looping the node, then check the size of the node and do the looping.

Regards

Nizamudeen SM