public class countDemo { static Integer count; public static void main(String[] args) { for(int i = 0;i<6;i++){ count++; } System.out.println(count); } }
这样为什么会报null指针异常呢,为什么不可以++呢
第二个问题:
public class User implements java.io.Serializable { private Integer userId; private String userName; private String password; private String mobile; private String email; @Override public String toString() { return "User [email=" + email + ", mobile=" + mobile + ", password=" + password + ", userId=" + userId + ", userName=" + userName + "]"; } }
为什么要在类上要实现implements java.io.Serializable 类?
public class User implements java.io.Serializable {
为什么要这样重写类里面的属性?
public String toString() { return "User [email=" + email + ", mobile=" + mobile + ", password=" + password + ", userId=" + userId + ", userName=" + userName + "]"; }