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...
Type: Posts; User: Norm
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...
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.
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...
What line(s) of code in all that was posted are you talking about?
What problem are you working on?
Post the code that you are asking about.
Using a variable with a null value is the cause of the 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...
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?
Go back through the code and find out why the null variable never got a valid value.
What is the value of vehicle?
What class needs the reference to a pShowVehicle object? Pass it in that class's constructor.
It would if it were called. Where is it called?
Why not pass the reference in the constructor?
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.
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...
What variable has the null value?
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.
What was the value in the pnlShow variable? If it was null, where should it be given a value?
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...
The method belongs to class of object passed to the catch block.
}catch(Exception x) {
x.printStackTrace();
}
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...
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.
Please copy the full text of the error message and paste it here. It has important info about the error.