Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27
  1. #21
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    The problem is the output of the
    Java Code:
    child2.setAttribute("calc_neutral_pep_mass", massaInfo);
    Every time that one is printed now I get the same value.

    But what I calculated (sum1) is what I need to be printed behind the calc_neutral_pep_mass.
    So I exported sum1 out of the loop to the child2.setAttribute....
    Every time the program runs the while loop the value is a diffrent one, because every time the sum1 is calculated again for a new set of values.

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default

    Every time that one is printed now I get the same value.
    If you don't change anything it SHOULD ALWAYS get the same value.

  3. #23
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    How do you meen?

    The sum1 that is stored in the arrayList is every time diffrent.
    And then I take out the last one stored, and let that one print behind the child.setAttribute.....
    Last edited by Lund01; 08-28-2011 at 07:12 PM.

  4. #24
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default

    For example:
    Java Code:
    int x = 1234;
    for (int i=0; i < 10; i++) {
      System.out.print("x=" + x);  // print value of x (will always be the same)
    } // end for(i)

  5. #25
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    Any idea on what line of code I then need to add on that part you explained above?

  6. #26
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default

    No I have no idea. If a variable is not changing in value and you think it should be changing, you need to back track through your code to see why it is not changing. An interactive debugger is useful for doing that. Otherwise add lots of println statements to your code to track how variables are changing.

  7. #27
    killer8889 is offline Member
    Join Date
    Aug 2011
    Posts
    3
    Rep Power
    0

    Default

    I found the solution for your problem regarding ArrayList. It was in a forum, may be that helps youUse of Collection Class in JAVA-- ArrayList


Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 12
    Last Post: 07-07-2011, 09:49 PM
  2. Replies: 11
    Last Post: 01-14-2011, 07:36 PM
  3. Replies: 7
    Last Post: 11-22-2010, 02:26 PM
  4. printing two smallest numbers from a series of numbers
    By trofyscarz in forum New To Java
    Replies: 2
    Last Post: 10-15-2008, 12:46 AM
  5. Replies: 2
    Last Post: 04-21-2008, 12:43 PM

Posting Permissions

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