Results 1 to 6 of 6
  1. #1
    mensa is offline Member
    Join Date
    Apr 2008
    Posts
    4
    Rep Power
    0

    Default 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:)

  2. #2
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    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.
    Did this post help you? Please me! :cool:

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    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.

  4. #4
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    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.
    My IP address is 127.0.0.1

  5. #5
    mensa is offline Member
    Join Date
    Apr 2008
    Posts
    4
    Rep Power
    0

    Default

    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

  6. #6
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    7

    Default

    - 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.
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

Similar Threads

  1. NullPointerException
    By ravian in forum New To Java
    Replies: 2
    Last Post: 12-07-2007, 05:20 PM
  2. NullPointerException
    By Feng in forum New To Java
    Replies: 5
    Last Post: 11-24-2007, 08:51 PM
  3. nullPointerException problem
    By conandor in forum Networking
    Replies: 1
    Last Post: 08-14-2007, 02:22 PM
  4. NullPointerException problem
    By warship in forum AWT / Swing
    Replies: 5
    Last Post: 08-10-2007, 05:43 PM
  5. ERROR: nullPointerException
    By mathias in forum New To Java
    Replies: 1
    Last Post: 08-05-2007, 07:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •