Search:

Type: Posts; User: Dr.HughMan

Search: Search took 0.07 seconds.

  1. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    Finally got it to work! Thanks a million!
  2. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    I'm thinking I have to make a counter and increment it when a module is assigned but I dont know how or where to put it?
  3. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    Im sorry but I dont understand this.How will it move to the next slot in the array to add the next module?
  4. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    Here is my code as it stands now;


    package Assignment6;

    public class Module {

    protected
    String code;
    String title;
  5. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    Am I heading in the right direction with this?


    package Assignment6;

    public class Student {

    protected String name;
    int id;
    String programme;
  6. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    Sorry but I dont understand this.
  7. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    Thank you for all your suggestions.

    Here is my code as it stands now


    package Assignment6;

    public class Module {

    protected
  8. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    The output im looking for is

    Name: John Johnson
    ID No.: 123456
    Programme: Electronic Engineering
    Module Code:EE219
    Moule Title:OOP
    Result:57.2%
    Module Code:EE203
    Moule Title:Maths
  9. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    Thank you that has sorted my Null Pointer Exception error.

    The programm now compiles and runs ok but is not outputing the correct information.

    package Assignment6;

    public class Module {
    ...
  10. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    Does this not happen when in my main at

    "Module [] modules = new Module [4];" ?
  11. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    "this.modules[i] = modules[i];" was supposed to assign it?
  12. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    I believe the null variable is "this.modules"

    I think it is null as the constructor does not seem to assign it the array that I pass to it.
  13. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    In my main of the student Class I create an array of modules with four modules, then the Student constructer is supposed to assign this array(modules) to the array Module [] modules that I declare at...
  14. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    When I print out this.modules and modules on line 21 I get
    "[LAssignment6.Module;@13e8d89
    null"

    And when I try to print out Module and modules on line 33 I get nothing and it wont let me print...
  15. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    and this is line 33

    Module.display(modules[i]);
  16. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    Sorry this is line 21

    this.modules[i] = modules[i];
  17. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    When I modify the code to print out contents of line 21




    protected String name;
    int id;
    String programme;

    public Module[] modules;
  18. Replies
    35
    Views
    5,207

    Re: Help with null pointer exception

    Thanks for the suggestion!

    But I still cant see how to fix it. When I print out the modules on line 21 it gives me the addresses of each module in the array. Which only confuses me more:(

    Any...
  19. Replies
    35
    Views
    5,207

    Help with null pointer exception

    Hi there,
    I am trying to do this question as part of an assignment but I just can't get it to work properly.


    "Write a class called Module that has a module code, title and a result (e.g. MM105...
Results 1 to 19 of 19