The solutions mentioned below are given by different people. Check it out which will work out for your application. Solution 1: Null Pointer Exceptions usually occur when you try to use an object that has been declared but not yet instantiated. Let's say you declared an ArrayList in your code, e.g. private ArrayList someList. If you attempt to use someList without first instantiating the list: someList.add(object o); without first calling someList = new ArrayList(), you would get a null pointer Exception. Fixing null pointer exceptions is code dependent. There is no overall solution: it depends on what caused the exception. Solution 2: Don't invoke operations on null objects. You can test for the reserved word null before calling a method. Sometimes it is valid for a variable to contain a null reference. In order to "fix" a null variable you need to look at where you think you should be constructing the object in question and see what's going wrong...
About Java and it's related concepts..