public class App1 {
public static void main(String[] args) {
System.out.println(addToString("12345678910",','));
}
public static StringBuffer addToString(String s, char c) {
StringBuffer b = new StringBuffer(s);
int p = 0;
for (int i = 1; i < b.length(); i++) {
if (i%3 == 0) {
b.insert(b.length()-i-p, c);
p++;
}
}
return b;
}
}
Login in to like
Login in to comment