主题:[讨论]java请教,高手请帮忙
public class continuedemo{
public static void main(String []args){
StringBuffer searchMe=new StringBuffer("perther piper pickedapeckofpickledpeppers");
System.out.println(searchMe);
int max=searchMe.length();
int numpe=0;
for(int i=0; i<max;i++){
if(searchMe.charAt(i)!='P')
continue;
numpe++;
searchMe.setCharAt(i,'P');
}
System.out.println("found"+numpe+"P's in the string.");
System.out.println(searchMe);
}
}
怎么答案会是found0P's in the string
perther piper pickedapeckofpickledpeppers
public static void main(String []args){
StringBuffer searchMe=new StringBuffer("perther piper pickedapeckofpickledpeppers");
System.out.println(searchMe);
int max=searchMe.length();
int numpe=0;
for(int i=0; i<max;i++){
if(searchMe.charAt(i)!='P')
continue;
numpe++;
searchMe.setCharAt(i,'P');
}
System.out.println("found"+numpe+"P's in the string.");
System.out.println(searchMe);
}
}
怎么答案会是found0P's in the string
perther piper pickedapeckofpickledpeppers