`

Cannot make a static reference to the non-static field email

阅读更多
     之所以会报Cannot make a static reference to the non-static field email这个错,是因为在静态方法中,不能直接访问非静态成员(包括方法和变量)。因为,非静态的变量是依赖于对象存在的,对象必须实例化之后,它的变量才会在内存中存在。
       因此,这个东西解决起来特别简单,第一种,可以把变量改成静态的。第二种,先实例化对象,然后使用对象名.变量名来调用即可。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics