小编Pnu*_*utz的帖子

如何制作Java ArrayList的深层副本

可能重复:
如何克隆ArrayList并克隆其内容?

试图制作一个ArrayList的副本.底层对象很简单,包含字符串,整数,BigDecimals,Dates和DateTime对象.如何确保对新ArrayList所做的修改不会反映在旧的ArrayList中?

Person morts = new Person("whateva");

List<Person> oldList = new ArrayList<Person>();
oldList.add(morts);
oldList.get(0).setName("Mortimer");

List<Person> newList = new ArrayList<Person>();
newList.addAll(oldList);

newList.get(0).setName("Rupert");

System.out.println("oldName : " + oldList.get(0).getName());
System.out.println("newName : " + newList.get(0).getName());
Run Code Online (Sandbox Code Playgroud)

干杯,P

java arraylist deep-copy

50
推荐指数
2
解决办法
13万
查看次数

Java Spring JdbcTemplate

JdbcTemplate对象和SimpleJdbcTemplate之间有什么区别?

java spring jdbc jdbctemplate

2
推荐指数
2
解决办法
6852
查看次数

git reset 后开发人员无法推送到受保护的分支

任何人都可以解释为什么我的团队成员在提交此 git reset 命令后无法将更改推送到 master 分支(更改将使 repo 恢复几次提交):

git reset --hard (previous commit SHA)
Run Code Online (Sandbox Code Playgroud)

这是尝试 git push 后收到的错误:

 ! [rejected]            master -> master (non-fast-forward)
error: failed to push some refs to 'git@xxxxx.com:xxx/xxxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)

分支 master 受到保护,因此只有“开发人员 + 维护人员”可以推送到它。

我的队友是有问题的 Gitlab …

git gitlab

0
推荐指数
2
解决办法
3191
查看次数

标签 统计

java ×2

arraylist ×1

deep-copy ×1

git ×1

gitlab ×1

jdbc ×1

jdbctemplate ×1

spring ×1