此文一出,必然让天下人耻笑.但此错误,切实让我感受到弄清概念是多么重要的一回事.代码仅为说明问题而写:

 1static fields and static methodpublic class client 
 2}
调用这访问类
static fields and static methodclass DbOper
    }

这个例子意在说明类的形成过程:
static fields ----->static method-------->constructor method -------->others
由此可见,在我们调用 getProduct 的时候,构造函数还没有执行,所以conn 对象还没有被初始化.

相关文章: