Results 1 to 3 of 3
  1. #1
    alwin is offline Member
    Join Date
    May 2008
    Posts
    1
    Rep Power
    0

    Default trying to do a cumulative addition and getting a null pointer exception

    if (a!= null ){
    b.setClaSubBalance(new Double(b.getClaSubBalance().doubleValue() + a.getClaSubBalance().doubleValue()));
    }
    where a and b are objects of a class.

    In the very first loop the values in b will be null. How can I handle this.

  2. #2
    JT4NK3D's Avatar
    JT4NK3D is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Default

    I really don't understand that thing in brackets but why not just give b an initial value of 0 or something?
    You just got T4NK3D!
    Adonrcicg to rcesraeh the haumn mnid is clbapae of rdanieg tihs. -Jvaa Sun Moricyssemts-

  3. #3
    chaster is offline Member
    Join Date
    Mar 2008
    Posts
    6
    Rep Power
    0

    Default

    Hi,
    What a surprise :) a and b are objects of calsses...
    Have you tried:
    TypeOfB = new TypeOfB(params);
    That will initialize variable b, which is not null anymore.

Similar Threads

  1. Null pointer Exception
    By peiceonly in forum New To Java
    Replies: 8
    Last Post: 09-05-2010, 06:48 PM
  2. [SOLVED] Cant figure out null pointer exception
    By todd2230 in forum New To Java
    Replies: 6
    Last Post: 05-06-2008, 07:45 AM
  3. Replies: 2
    Last Post: 05-01-2008, 10:14 AM
  4. Null pointer exception error
    By brownie_jedi in forum New To Java
    Replies: 3
    Last Post: 03-15-2008, 06:27 AM
  5. statement null pointer exception
    By bbq in forum JDBC
    Replies: 1
    Last Post: 07-05-2007, 04:23 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
  •