Java clone()??????????÷?
???????????? ???????[ 2013/12/6 10:53:25 ] ????????
????????????????Java??????????????????????????????????Java???????????????????????????"???????"???????????????????????"????"?????"????"??????C?????е????????????????????????????????????????????????????????????????????
???????????????????????"???????"?????κ???"??"??????????????????"???????"???磺
A a1=new A();
A a2=new A();
a1.name="a1";
a2=a1;
a2.name="a2";
System.out.println("a1.name="+a1.name);
System.out.println("a2.name="+a2.name);
|
?????????????????
????a1.name=a2
????a2.name=a2
??????????????a2????a1??????????????????a2??????????????????a1?????clone??????????????????????Ч????Ρ?
?????????????????A??clone????
public class A implements Cloneable {
public String name;
public Object clone() {
A o = null;
try {
o = (A) super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return o;
}
}
|
????????????Cloneable?????????????clone??????????clone()?????е?????super.clone()???????ζ??????clone????н??????????super.clone()???????????java.lang.Object???clone()??????
A a1=new A();
A a2=new A();
a1.name="a1";
a2=a1;
a2.name="a2";
System.out.println("a1.name="+a1.name);
System.out.println("a2.name="+a2.name);
|
?????????????????
????a1.name=a1
????a2.name=a2
??????Class A?????????????java???????????????String???????????????????clone???????clone??????????????Class A?????????????????????????????????clone??
public class A implements Cloneable {
public String name[];
public A(){
name=new String[2];
}
public Object clone() {
A o = null;
try {
o = (A) super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return o;
}
}
|
???????????
A a1=new A();
A a2=new A();
a1.name[0]="a";
a1.name[1]="1";
a2=(A)a1.clone();
a2.name[0]="b";
a2.name[1]="1";
System.out.println("a1.name="+a1.name);
System.out.println("a1.name="+a1.name[0]+a1.name[1]);
System.out.println("a2.name="+a2.name);
System.out.println("a2.name="+a2.name[0]+a2.name[1]);
|
????????????
????a1.name=[Ljava.lang.String;@757aef
????a1.name=b1
????a2.name=[Ljava.lang.String;@757aef
????a2.name=b1
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Java???????????Щ???????????????Java????????????????Java?б???Map????????Java Web???????????????Java??????????????д?????Java????????7???????????????????????(java .net ?????)???Java??????????Python??????Java webdriver??λ????????′????е?????Java??д??????????????????Java???????????????JavaScript????????????Java?????????????????? Java???????10??????????????Java?м????????????????java???????ü???????????м???????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????