Results 1 to 6 of 6

Thread: What is java.lang.NullPointerException

  1. #1
    Join Date
    Dec 2009
    Posts
    211

    What is java.lang.NullPointerException

    Hello,
    I wonder what does the error:java.lang.NullPointerException means?. I have seen this error in my code many time , but I do not know what exactly this means, if you have an explanation for this then it would be great. Thanks in advance.

  2. #2
    Join Date
    Nov 2009
    Posts
    343

    Re: What is java.lang.NullPointerException

    Hello,
    This error occurs we call a method on an uninitialized variable.
    For example:
    Code:
    mObject tmp;
    tmp.exMethod ();
    Causes NullPointerException.
    To help should show us the source code. And also if you need an example on this and an explanation then visit the Sun's official site for more information.

  3. #3
    Join Date
    Nov 2009
    Posts
    446

    Re: What is java.lang.NullPointerException

    Hello,
    Check out this example for more understanding

    Code:
    Public class mobj{
     
    Public mobj()
    {
    ...
    }
     
    Public int exmethod(){
    ...
    }
     
    Public static void hand(String[] args){
    mobj o;
    int value = o.exmethod();
    }

  4. #4
    Join Date
    Dec 2009
    Posts
    211

    Re: What is java.lang.NullPointerException

    Hello,
    Here is my code:
    in the main class:
    Code:
      Public void actionPerformed(ActionEvent e)
           {
                   String tx = entry.getText();
                   se.selectAll();
                   se.cut();
                   add(login, tx);
                   
                   Sys.listen(login, tx);   / / answer in terms of tx 
           }
    See, if you can help me with this.

  5. #5
    Join Date
    Nov 2009
    Posts
    356

    Re: What is java.lang.NullPointerException

    Hello,
    I think your variable / attribute s has been initialized? I think you need to change this.
    Code:
    System.out.System.out.println(s == null);
    I am not sure but I think you have a problem in this line, see if you can eliminate this line from your code and try some other alternative for this.

  6. #6
    Join Date
    Nov 2009
    Posts
    359

    Re: What is java.lang.NullPointerException

    Hello,
    I think I have a solution for this . just have a look at the example below
    Code:
    / / Instantiate the dialog engine
    Sys s = new Sys (var, rulefile, "");
    
    but when it is sent to the following code:
    
    public void actionPerformed (ActionEvent e)
    {
    se.getText String tx = ();
    se.selectAll ();
    se.cut ();
    add (login, tx);
    
    Sys.cout (login, tx) / / answer in terms of tx
    }

Similar Threads

  1. Eclipse: java.lang.UnsatisfiedLinkError
    By Gadin in forum Software Development
    Replies: 5
    Last Post: 29-07-2010, 04:47 AM
  2. Error - java.lang.NumberFormatException
    By Vodka in forum Software Development
    Replies: 5
    Last Post: 05-03-2010, 11:57 AM
  3. Error Java.lang.OutOfMemoryError
    By Logan 2 in forum Software Development
    Replies: 5
    Last Post: 04-03-2010, 12:42 PM
  4. java.lang.NoClassDefFoundError: Classname
    By Learningj in forum Software Development
    Replies: 3
    Last Post: 09-11-2009, 08:59 AM
  5. NullPointerException when using array of string in Java
    By Sean J in forum Software Development
    Replies: 2
    Last Post: 25-04-2009, 08:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,710,831,588.74151 seconds with 16 queries