java基礎(chǔ)字符串代碼題,java編程基礎(chǔ)題

java面向?qū)ο蠡A(chǔ)題目(字符串)

選B,change函數(shù)的入口參數(shù)為str則只修改傳入?yún)?shù),若在函數(shù)體內(nèi)使用“this.str=str”則發(fā)生互換,第二個(gè)直接修改了引用值,導(dǎo)致發(fā)生改變。

創(chuàng)新互聯(lián)建站專注于安寧企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站設(shè)計(jì),商城系統(tǒng)網(wǎng)站開發(fā)。安寧網(wǎng)站建設(shè)公司,為安寧等地區(qū)提供建站服務(wù)。全流程按需網(wǎng)站開發(fā),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)

JAVA 字符串題,求快速完整作答!!急

public static void main(String[] args) { Scanner s=new Scanner(System.in); // process(s); process2(s); } public static void process(Scanner s) { String str; int[] count=new int[4]; int[] lowCount=new int[4]; int[] highCount=new int[4]; String[] lowStr=new String[4]; String[] highStr=new String[4]; while(true) { str=s.nextLine();// 這里用回車確認(rèn)輸入每一個(gè)字符串 if(str.equals("end")) { break; } char[] cc=str.toCharArray(); int[] tempCount=new int[4]; for(char c: cc) { switch(c) { case 'A': count[0]++; tempCount[0]++; break; case 'C': count[1]++; tempCount[1]++; break; case 'G': count[2]++; tempCount[2]++; break; case 'T': count[3]++; tempCount[3]++; break; default: System.out.println("Error!"); } } for(int i=0; i 4; i++) { if(lowCount[i] == 0) { lowCount[i]=tempCount[i]; lowStr[i]=str; } else if(lowCount[i] tempCount[i] tempCount[i] != 0) { lowCount[i]=tempCount[i]; lowStr[i]=str; } if(highCount[i] == 0) { highCount[i]=tempCount[i]; highStr[i]=str; } else if(highCount[i] tempCount[i]) { highCount[i]=tempCount[i]; highStr[i]=str; } } } System.out.println("A count: " + count[0]); System.out.println("C count: " + count[1]); System.out.println("G count: " + count[2]); System.out.println("T count: " + count[3]); System.out.println("Low A count: " + lowStr[0]); System.out.println("High A count: " + highStr[0]); System.out.println("Low C count: " + lowStr[1]); System.out.println("High C count: " + highStr[1]); System.out.println("Low G count: " + lowStr[2]); System.out.println("High G count: " + highStr[2]); System.out.println("Low T count: " + lowStr[3]); System.out.println("High T count: " + highStr[3]); } public static void process2(Scanner s) { int n=Integer.parseInt(s.nextLine()); String[] strs=new String[n]; int[] count=new int[n]; for(int i=0; i n; i++) { strs[i]=s.nextLine(); } while(true) { String temp=s.nextLine();// 這里用回車確認(rèn)輸入每一個(gè)字符串 if(temp.equals("end")) { break; } for(int i=0; i n; i++) { for(int j=0; j temp.length()-strs[i].length()+1; j++) { String temp2=temp.substring(j,j+strs[i].length()); if(temp2.equals(strs[i])) { count[i]++; } } } } for(int i=0; i n; i++) { System.out.println("Partten " + strs[i] + " count: " + count[i]); } }

java字符串替換題?

public class Test {

public static void main(String[] args) {

String input = "aaa果4金5a";

StringBuffer sb = new StringBuffer();

char[] c = input.toCharArray();

for (int i = 0; i c.length; i++) {

if (c[i] = '0' c[i] = '9') {

int tmp = Integer.valueOf(String.valueOf(c[i]));

for (int j = 0; j tmp; j++) {

sb.append(c[i + 1]);

}

i++;

} else {

sb.append(c[i]);

}

}

System.out.println(sb.toString());

}

}

標(biāo)題名稱:java基礎(chǔ)字符串代碼題,java編程基礎(chǔ)題
本文地址:http://muchs.cn/article24/phjsje.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、營(yíng)銷型網(wǎng)站建設(shè)手機(jī)網(wǎng)站建設(shè)、網(wǎng)站維護(hù)動(dòng)態(tài)網(wǎng)站、用戶體驗(yàn)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化