try内部定义的对象无法到外部使用,需要在try前声明定义该变量并为null
people p2 = null;// 需要添加该代码
try {
p2 = (people) p1.clone();
System.out.println(p1);
System.out.println(p2);
p2.setName("222");
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}