Avatar of yjchong514
yjchong514
Flag for United States of America

asked on 

String Processing

Dear EE members,

I would like to establish: http://codingbat.com/prob/p121596

Here is my code:
public String altPairs(String str) { //01 23 45 67 89 i=0,1 i=i+4,i+5
  String newStr = "";
  int counter = 0;
 
  while(counter<newStr.length()){
    if(counter==0||counter==1) newStr += str.charAt(0);  
   
    counter=counter+4;
    newStr += str.charAt(counter);
  }  
 
  return newStr;
}

Regards,

yjchong514
Java

Avatar of undefined
Last Comment
yjchong514

8/22/2022 - Mon