Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    What does that mean? You don't call a variable, you call a method in a class or a constructor for a class.

    In your code: vehicle is a variable of type Vehicle. It can hold a reference to an...
  2. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    The variable needs a non-null value when it is used.

    I have no idea if that line of code will work in your program. The line is completely out of context of the rest of the code.
  3. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    You have been through this type of problem before.
    Is the value of vehicle null?
    Why is it null?
    Where should the code have assigned it a value?
    It needs a value BEFORE it is used.

    I...
  4. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    What line(s) of code in all that was posted are you talking about?
    What problem are you working on?
  5. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    Post the code that you are asking about.
  6. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    Using a variable with a null value is the cause of the NullPointerException.
  7. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    No, that defines a variable that CAN refer to a Vehicle object. No object is created there. The new statement is used to create instances of a class.

    This statement in the main() method creates...
  8. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    If it has a null value, then it was not assigned a valid value.
    Is it ever assigned a value?
    Is it used BEFORE it is assigned a value?
  9. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    Go back through the code and find out why the null variable never got a valid value.
  10. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    What is the value of vehicle?
  11. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    What class needs the reference to a pShowVehicle object? Pass it in that class's constructor.
  12. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    It would if it were called. Where is it called?

    Why not pass the reference in the constructor?
  13. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    You need to assign a reference to an instance of the pShowVehicle class to the variable.
    An instance may already exist that could be used or a new one could be created with a new statement.
  14. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    That code is trying to print the value returned by the doSomething() method, but nothing is returned because it is void.
    The variable in that method is pnlShow. That is what could cause the...
  15. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    What variable has the null value?
  16. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    If that code was executed, the contents of taOrder should be "ZZZZZZZZZZZZZ"
    I haven't executed the code to know if taOrder is shown in the GUI when that code is executed.
  17. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    What was the value in the pnlShow variable? If it was null, where should it be given a value?
  18. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    There is a null value when the statement on line 131 is executed. Look at line 131, find the variable with the null value and then backtrack in the code to see why that variable does not have a...
  19. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    The method belongs to class of object passed to the catch block.


    }catch(Exception x) {
    x.printStackTrace();
    }
  20. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    The print out from the printStackTrace() method will show where the error happens. If you do not know the statement where the error happens, that makes it harder to find the error.
    The other choice...
  21. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    That is not enough. You need to get the full stack trace. Be sure that the printStackTrace() method is called in all the catch blocks so that the location of the error is shown.
  22. Replies
    44
    Views
    5,050

    Re: Having a NullPointerException

    Please copy the full text of the error message and paste it here. It has important info about the error.
Results 1 to 22 of 22