資源描述:
《java從入門到精通習(xí)題》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、5.3publicclassEval{//新建類publicstaticvoidmain(String[]args){//主方法Stringregex="1[35]\d{9}";Stringtext="15000000000";if(text.matches(regex)){System.out.println(text+"是合法的手機(jī)號(hào)");}}}5.4publicclassEval{//新建類publicstaticvoidmain(String[]args){//主方法StringBuilderbuilder=newStringBuilder("a");fo
2、r(inti=1;i<=10;i++){builder.append(i);}System.out.println(builder.toString());}}6.1importjava.util.*;publicclassEval{//創(chuàng)建類publicstaticvoidmain(String[]args){intarr1[]=newint[]{1,2,3,4,5};intarr2[]=Arrays.copyOf(arr1,3);//復(fù)制源數(shù)組中從下標(biāo)0開始的3個(gè)元素到目的數(shù)組,從下標(biāo)0的位置開始存儲(chǔ)。for(inti=0;i3、ystem.out.print(arr1[i]);System.out.println();for(intj=0;j4、.3importjava.util.*;publicclassText{//創(chuàng)建類publicstaticvoidmain(String[]args){Stringarr[]=newString[]{"ac","bc","dc","yc"};System.out.println("替換前:");for(Stringstr:arr){System.out.print(str+"t");}Arrays.fill(arr,2,3,"bb");System.out.println("替換后:");for(Stringstr2:arr){System.out.print
5、(str2+"t");}}}6.4publicclassEval{//創(chuàng)建類publicstaticvoidmain(String[]args){intarr[][]=newint[][]{{1,2,3},{4,5,6},{7,8,9}};System.out.println("數(shù)組原有內(nèi)容:");for(inti=0;i6、組內(nèi)容:");for(inti=0;i7、cclassUseCase2extendsUseCase1{publicstaticvoidmain(String[]args){UseCase1u=newUseCase1();u.setName("123");System.out.println(u.getName());}}7.2packagecom.lzw;publicclassUseCase3{privatefloatheight;privatefloatwidth;publicUseCase3(floatheight,floatwidth){this.height=height;this.width=