Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    Make it a class variable in the class where the array is. Its initial value of 0 will be where the first element is to go in the array then increment for the next element. Its value at any time will...
  2. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    If at any time you call the objectadd method to add an element to the array, where will it put that one element? How will it keep track of where the next empty element is located?
  3. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    Why the loop in objectadd()? It should add one object. The caller of object will call it for as many times as it wants to add a new Module to the student.
    In display you should use the length of the...
  4. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    What happens when you execute it?

    Look at the second part of post #25
  5. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    Which part don't you understand?
    1)add a method? see the display method. its a method that you pass a Module object to
    2)add objects to the array. See the Student class's constructor. It adds...
  6. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    You haven't followed my suggestions (which I see were not clear). You should NOT put your testing code into the Student class's constructor.
    Have main pass the size of the array to the Student...
  7. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    You should get rid of all static variables.

    Only the value of the last data assigned is present in all the instances because they are sharing one static variable instead of having their own...
  8. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    Please explain what the problem is and show what you want the output to look like.

    The output reminds me of problems using static variables.
    Only the value of the last data assigned is present in...
  9. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    That would define a variable: modules known only in the main method. The class variable with the same name would still not have a value.
    If you want to assign a value to the modules variable leave...
  10. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    Yes that assigns a value to one of the slots in an existing array, but you need to define it first.
    What if modules[] had 2 slots, would you be able to assign values to the 10th slot?
    Before you...
  11. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    Where do you assign a value to the "this.modules" variable? You define it but never give it a value.
  12. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    In your printout, What variable is null? Your print out does not have an id String with the null line.


    You read the stack trace from the bottom up.
    At line 54 in main() the code calls the...
  13. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    Which variable is null on line 21? Why is it null? Did you assign any value to that variable?


    Please explain. Do you mean it prints spaces or blanks?
    Change your println statement to have a...
  14. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    On line 21 You need to print out the value of this.modules and modules.
    On line 33 you need to print out the value of Module and modules.
  15. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    The error has moved to line 33. What variable on line 33 is null?

    You never posted line 21 so I can't help you determine which variable on that line is null.
  16. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    What variable is null?
    Post the contents of line 21 if you need help finding the variables that are used on that line.
  17. Replies
    35
    Views
    5,241

    Re: Help with null pointer exception

    look at line 21 in the Student class. There is a variable there with a null value. Backtrack in your code to find out why and fix the code so that the variable has valid value.
    If you can not see...
Results 1 to 17 of 17