Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 27-02-2010
Member
 
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.
Reply With Quote
  #2  
Old 27-02-2010
Member
 
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.
Reply With Quote
  #3  
Old 27-02-2010
Member
 
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();
}
Reply With Quote
  #4  
Old 27-02-2010
Member
 
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.
Reply With Quote
  #5  
Old 27-02-2010
Member
 
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.
Reply With Quote
  #6  
Old 27-02-2010
Member
 
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
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What is java.lang.NullPointerException"
Thread Thread Starter Forum Replies Last Post
Eclipse: java.lang.UnsatisfiedLinkError Gadin Software Development 5 29-07-2010 04:47 AM
Error - java.lang.NumberFormatException Vodka Software Development 5 05-03-2010 11:57 AM
Error Java.lang.OutOfMemoryError Logan 2 Software Development 5 04-03-2010 12:42 PM
java.lang.NoClassDefFoundError: Classname Learningj Software Development 3 09-11-2009 08:59 AM
NullPointerException when using array of string in Java Sean J Software Development 2 25-04-2009 08:14 PM


All times are GMT +5.5. The time now is 12:50 PM.