Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Error Message on Java Compiler

  • 22-03-2004 2:24pm
    #1
    Registered Users, Registered Users 2 Posts: 488 ✭✭


    Exception in thread "main" java.lang.NullPointerException
    at Directory.main(Directory.java:26)

    Anyone know what the problem is....


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    The problem is in line 26 of Directory.java

    beyond that you don't have enough information to supply a proper answer.


  • Registered Users, Registered Users 2 Posts: 1,636 ✭✭✭henbane


    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/NullPointerException.html probly doesn't help and awful lot but is as good a place as any to start.

    Twould be a good idea to post a little code when you want answers to this kind of thing. Or possibly just go to java.sun.com first


  • Registered Users, Registered Users 2 Posts: 488 ✭✭lad12


    On line 26 i use an array to read in information...

    Array.get();

    and in the method get i read in 2 strings and an int from the keyboard...can you read in 3 parts of information into 1 component of the array...


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Doesn't seem to make a whole pile of sense.
    Post up your whole code, so we have proper context.


  • Registered Users, Registered Users 2 Posts: 1,636 ✭✭✭henbane


    Originally posted by lad12
    Array.get();
    Looks like i might be reaching a value larger than the size of the array.
    and in the method get i read in 2 strings and an int from the keyboard...can you read in 3 parts of information into 1 component of the array...

    If you have created a class with the relevant attributes and the array is of that type, it shouldn't be a problem.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 491 ✭✭Silent Bob


    Originally posted by lad12
    Exception in thread "main" java.lang.NullPointerException
    at Directory.main(Directory.java:26)

    Anyone know what the problem is....
    It means you've tried to reference something that quite simply does not exist. The usual culprit is iterating over the end of an array, or trying to call a method on a reference which has been set to null.


  • Closed Accounts Posts: 1,502 ✭✭✭MrPinK


    I'm guessing you created an array of objects, but didn't initialise them. It's a little different than creating an array of primative types.
    int[] Array = new int[10];
    // that works fine alright
    
    myObject[] Array = new myObject[];
    // not done yet. You've only created the refs to the objects....
    for(int i = 0; i < 10; i++)
       Array[i] = new myObject();
    // now you have an created all the objects
    

    This wouldn't happen to be a Joe Morris assignment, would it? :)


Advertisement