Results 1 to 3 of 3
  1. #1
    vasavi.singh is offline Member
    Join Date
    Feb 2009
    Posts
    24
    Rep Power
    0

    Default 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

  2. #2
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    7

    Default

    Please use code tags - I can't read this...
    I die a little on the inside...
    Every time I get shot.

  3. #3
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    it also helps to indicate the actual location of the exception.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •