public class MyClass {
public static String reverse_first_n_chars(String s, int pos) {
String tmp = s. substring(0, pos);
int len = s.length();
s = new StringBuilder(tmp).reverse().toString() + s.substring(pos, len);
return s;
}
public static void main(String args[]) {
String s = "python programming";
int pos = 3;
System.out.println(reverse_first_n_chars(s, pos));
}
}
/*
run:
typhon programming
*/