-
NullPointerException
i am novice in oop & java, i have a problem with this error :
"Exception in thread "main" java.lang.NullPointerException"
when i want to try create new object, these lines of my code cause it
public void AddManager (Manager m){
managers[managerIndex++] = m;(in my manager class &)
n= new Manager(manName,salary,numberProject);
boss.AddManager(n); (in my main class)
plz help me:)
-
Hello mensa,
Welcome to the Java Forums.
Somewhere in your code a null value is being returned. Can you post the code from all your classes here and please put the [code] [/ code] tags around it. (Minus the space after /)
Thank you.
-
Provide some code to see pal. As Don says your code return a null value, looking at few code lines you have provide can't say much.
-
It should tell you where your calling the object that is null. Thankfully your working in Java because in c++ it would just find a spot in ram and call that your data, and whatever arbitrary data was there before your program now thinks that represents your object.
-
hello DonCash,
i wated to attach my code but i could't , then i inserted my code in my message but it failed again and this error occured:
"The site could be temporarily unavailable or too busy. Try again in a few
moments.
If you are unable to load any pages, check your computer's network
connection.
If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web. "
i have no firewall & proxy , is any way to solve it?
THK
-
- managers array could be null
- Manager(manName,salary,numberProject) constructor can do something that with the parameters and a parameter could be null
- boss instance could be null
- n could be null and boss.AddManager(n); can try to do something with n
Unless you post your full code we cannot point to the exact error.