ArrayIndexOufOfBoundException
hi
I wrote a program in which I am reading the data from an input file. It is stored in an array. Using that data I am creating objects. When I am displaying the length of the array it shows 278 as the length. In a for loop I am creating the object. This loop will continue upto the end of the array. At the middle only it raising the ArrayIndexOutOfBoundException. Can u help me regarding this.
The program as follows:
Main1.java
public class Main1
{
public static void main(String args[]) throws IOException
{
StoreDataInAFile fileObj=new StoreDataInAFile();
SocialNetworkCons1 network=new SocialNetworkCons1();
String data[]=fileObj.readDataFromAFile();
LinearThresholdModel model=new LinearThresholdModel();
System.out.println("Number of elements: "+data.length);
network.constructingSocialNetwork(data);
}
}
This is the method of SocialNetworkCons.java
public void constructingSocialNetwork(String[] tkn)
{
for(int i=0;i<tkn.length; )
{//creating article nodes
System.out.println("i value: "+i); // printing i value
System.out.println("The number of elements in the array are "+tkn.length); // printing array length for cross verification
int index=createArticleNode(tkn,i) - 1;
System.out.println("The entered node is stored in network with index number "+index);
for(j=0;j<agent[index].getNoOfAuthors();j++)
{//creating author nodes
r=i+5+j*4;
System.out.println("The "+r+"th data is passing to the function.");
temp=createAuthorNode(tkn,r,index);
authorsId[j]=temp-1;
System.out.println("The entered node is stored in network with index number +
authorsId[i]);
}
System.out.println("Connections are going to establish");
//createEdgeBetweenAuthors(authorsId,agent[index].getNoOfAuthors());
// Connection establishment
//System.out.println("The connection are established between the authors");
i=i+5+j*4;
}
}
In the methods just using the data no more modifications are done.
Respond as soon as possible