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

    Default java.lang.NullPointerException

    I initialized the author object array. I applied some changes to the data of the author array also. To send that code its very large program of 3-4 hundred lines.

    I will send some information, probably it may use full while debugging.


    <code>
    public int constructingSocialNetwork(String[] tkn)
    {
    for(int i=0;i<tkn.length; )
    {//creating article nodes
    System.out.println("i value: "+i);
    System.out.println("The number of elements in the array are "+tkn.length);
    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[j]);
    }
    System.out.println("Connections are going to establish");
    createEdgeBetweenAuthors(authorsId,agent[index].getNoOfAuthors()); // Connection
    System.out.println("The connection are established between the authors");
    if(r+4 == tkn.length)
    {
    System.out.println("End of the array.");
    int x=temp+m-1;
    System.out.println("Number of author nodes: "+(temp-1));
    System.out.println("Number of article nodes: "+m);
    System.out.println("Number of nodes: "+x);
    findingNewNeighbors(temp-1);
    displayWeightBetweenAuthors(temp-1);
    displayWeightBetweenAuthorsAndArticle(temp-1,m);
    displayingThreshold(temp-1);
    displayDegree(temp-1);
    int highestDegree=maxDegreeOfAuthors(temp-1);
    calculateDegreeOfAuthors(highestDegree,temp-1);
    }
    i=i+5+agent[index].getNoOfAuthors()*4;
    }
    return temp-1;
    }
    </code>

    Based on the data what I received as a parameter in the above function, that data is used to create 2 types of object. Here I would like to use Author class object array. The returned value of this function will be passed as argument for methodImplementation().

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    7

    Default

    i think you need to modify constructingSocialNetwork to accept SocialNetworkCons xxx input
    as SocialNetworkCons network in LinearThresholdModel class is not the same object as network in Main class

  3. #3
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    7

    Default

    Java Code:
    int degree=network.author[i].getDegree(); // raising exception
    network in LinearThresholdModel object
    is not the network in Main Class, they are two difference object

    network in Main main method seem access the file
    but network in LinearThresholdModel object have not access the file by calling constructingSocialNetwork method

  4. #4
    vasavi.singh is offline Member
    Join Date
    Feb 2009
    Posts
    24
    Rep Power
    0

    Default java.lang.NullPointerException

    Thank You.

    What you specified as the mistake that is reason for raising exception. Later I tried with putting if condition where the object author value is null. At the beginning only it is giving null value. Later I recognized the reason for exception.

    Thank You.

Similar Threads

  1. java.lang.NullPointerException
    By vasavi.singh in forum New To Java
    Replies: 2
    Last Post: 02-27-2009, 11:11 AM
  2. java.lang.NullPointerException
    By stevemcc in forum AWT / Swing
    Replies: 2
    Last Post: 02-08-2008, 10:01 AM
  3. java.lang.NullPointerException
    By ravian in forum New To Java
    Replies: 1
    Last Post: 01-13-2008, 08:39 PM
  4. Replies: 2
    Last Post: 07-16-2007, 07:21 AM
  5. java.lang.NullPointerException
    By Felissa in forum Advanced Java
    Replies: 1
    Last Post: 07-05-2007, 07:02 AM

Posting Permissions

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