資源描述:
《張孝祥IT課堂-《Java就業(yè)培訓(xùn)教程》書(shū)籍源碼03》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫(kù)。
1、《Java就業(yè)培訓(xùn)教程》P81源碼
classCompare
{
publicstaticvoidmain(String[]args)
{
Stringstr1=newString("abc");
Stringstr2=newString("abc");
Stringstr3=str1;
if(str1==str2)
System.out.println("str1==str2");
else
System.out.println("str1!=str2");
if(str1==str3)
System.ou
2、t.println("str1==str3");
else
System.out.println("str1!=str3");
}
}
《Java就業(yè)培訓(xùn)教程》P82源碼
classCompare
{
publicstaticvoidmain(String[]args)
{
Stringstr1=newString("abc");
Stringstr2=newString("abc");
Stringstr3=str1;
if(str1.equals(str2))
System.out.println("s
3、tr1equalstr2");
else
System.out.println("str1notequalstr2");
if(str1.equals(str3))
System.out.println("str1equalstr3");
else
System.out.println("str1notequalstr3");
}
}
《Java就業(yè)培訓(xùn)教程》P86源碼
classPerson
{
privateintage;
publicvoidsetAge(inti)
{
if(i<0
4、
5、i>130)
6、return;
age=i;
}
publicintgetAge()
{
returnage;
}
}
publicclassTestPerson
{
publicstaticvoidmain(Stringargs[])
{
Personp1=newPerson();
p1.setAge(3);
p1.setAge(-6);
System.out.println(p1.getAge());
}
}
《Java就業(yè)培訓(xùn)教程》P88源碼
classPerson
{
publicPerson()
{
System
7、.out.println("theconstructor1iscalling!");
}
privateintage=10;
publicvoidshout()
{
System.out.println("ageis"+age);
}
}
classTestPerson
{
publicstaticvoidmain(String[]args)
{
Personp1=newPerson();
p1.shout();
Personp2=newPerson();
p2.shout();
Personp3=newPe
8、rson();
p3.shout();
}
}
《Java就業(yè)培訓(xùn)教程》P90源碼
classPerson
{
privateStringname="unknown";
privateintage=-1;
publicPerson()
{
System.out.println("constructor1iscalling");
}
publicPerson(Stringn)
{
name=n;
System.out.println("constructor2iscalling");
System.out.p
9、rintln("nameis"+name);
}
publicPerson(Stringn,inta)
{
name=n;
age=a;
System.out.println("constructor3iscalling");
System.out.println("nameandageis"+name+";"+age);
}
publicvoidshout()
{
System.out.println("listentome!!");
}
}
classTestPerson
{
publicstaticvo
10、idmain(String[]args)
{
Personp1=newPerson();
P1.shout();
Personp2=newPerson("Jack");
P2.shout();
Personp3=newPerson("Tom",18);
P3.shout();
}
}
《Java就業(yè)培訓(xùn)教程》P94源碼
classPerson
{
privatePerson()
{
System.o