It is simply not possible for you to code an application so that there are zero NPE thrown. You can, if you wish, catch them all, and prevent them from being seen by your user.
If you are asking how to you find and fix them in your code, the usual method is to set a breakpoint in the
IDE that you are using, and trigger it.
There are times when throwing a Null Pointer Exception is the proper thing for a method to do.