public class ArraysL {
public static void main(String[] args) {
String str = "abcdef";
reverse(str, 1, 4);
}
public static void reverse(String str, int start, int end) {
char[] chars = str.toCharArray();
char temp = ' ';
if((start<0&&end> chars.length&&start>end)){
throw new RuntimeException("wrong");
}
try {
for (int i = start, j = end; i < j; i++, j--) {
temp = chars[i];
chars[i] = chars[j];
chars[j] = temp;
}
} catch (java.lang.Exception e) {
System.out.println("wrong");
return;
}
System.out.println(Arrays.toString(chars));
}
}