選B,change函數(shù)的入口參數(shù)為str則只修改傳入?yún)?shù),若在函數(shù)體內(nèi)使用“this.str=str”則發(fā)生互換,第二個直接修改了引用值,導(dǎo)致發(fā)生改變。
創(chuàng)新互聯(lián)建站專注于安寧企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站設(shè)計,商城系統(tǒng)網(wǎng)站開發(fā)。安寧網(wǎng)站建設(shè)公司,為安寧等地區(qū)提供建站服務(wù)。全流程按需網(wǎng)站開發(fā),專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)
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)輸入每一個字符串 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)輸入每一個字符串 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]); } }
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());
}
}