English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2 answers

http://java.sun.com/
http://jspwiki.org
http://java.about.com/cs/beginningjava/a/comm_errs.htm

2006-08-23 04:53:19 · answer #1 · answered by Shaik Umar 2 · 0 0

You didn't post the code that is causing the NullPointerException to be raised. In general, this means you tried to reference an object that has not been instantiated. Here is an example:


public class Example{
private String name;

public Example(){
//should instantiate name
//name = "Example name";
}

public int getLength(){
/*if name is null, then you will get NullPointer exception
thrown on this next line of code! This is
because the variable "name" has no value (i.e. is null)*/
int length = name.length();

public static void main(String[] args){
Example ex = new Example();
int len = ex.getLength();
System.out.println("Example's name length is " + len);
}
}

2006-08-25 04:32:32 · answer #2 · answered by vincentgl 5 · 0 0

fedest.com, questions and answers