Welcome to the Ranch. The code you posted is a little bit hard to read. Please
use code tags, so that the forum software can properly format your code.
Member variables are initialized to
null by default (if you don't initialize them explicitly). In your first example, the member variable
commonDao will be
null, because you don't initialize it. If you try to call a method on a variable that's
null, you'll get a
NullPointerException. It must be initialized to refer to some object before you try to call any methods on it.