public class ArrayTssst {
public static void main(String[] args){
// int[] a = new int[]{1,15,3};
/*int[] b = a;
System.out.println(b[1]);*/
/* int[] b = new int[3];
System.arraycopy(a, 0, b, 0, a.length);
b[1] =55;
for(int i=0;i<a.length;i++){
System.out.println(a[i]);
}*/
Poin[] p1 = new Poin[]{new Poin(1,1),new Poin(2,2),new Poin(3,3)};
Poin[] p2 = new Poin[3];
/*System.arraycopy(p1, 0, p2, 0, p1.length);
p2[2].x = 44;
p2[2].y = 33;
for(int i=0;i<p1.length;i++){
System.out.println(p1[i]);
}*/
p2 = p1.clone();
p2[2].x = 44;
p2[2].y = 33;
for(int i=0;i<p1.length;i++){
System.out.println(p1[i]);
}
}
}
class Poin implements Cloneable{
int x;
int y;
Poin(int x,int y){
this.x = x;
this.y = y;
}
public String toString(){
return "x = "+x+", y = "+y;
}
public Object clone(){
Object o=null;
try {
o = super.clone();
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return o;
}
}
摇曳的蔷薇
慕码人8056858
相关分类