package ;
public class SsytemArrayCopy {
public static void main(String[] args) {
User [] users=new User[]{new User(1,"admin","admin@"),new User(2,"maco","maco@qq,com"),new User(3,"kitty","kitty@qq,com")};
User [] target=new User[];
(users, 0, target, 0, );
("源对象与目标对象的物理地址是否一样:"+(users[0] == target[0]?"浅复制":"深复制"));
target[0].setEmail("admin@");
("修改目标对象的属性值后源对象users:");
for (User user : users){
(user);
}
}
}
class User{
private Integer id;
private String username;
private String email;
public User() { }
public User(Integer id, String username, String email) {
super();
this.id = id;
this.username = username;
this.email = email;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return "User [margin:0px; padding:0px; border:none; background-color:inherit"> + id + ", username=" + username + ", email=" + email
+ "]";
}
}