package com.test;
public class TestString {
public static void main(String[] args) {
String s = "Hello"; s = reverse(s, 2, 4); System.out.println(s); }public static String reverse(String s, int f, int t) {
char[] c = new char[s.length()]; for (int i = 0; i < s.length(); i++) { if (f - 1 == i || i == t - 1) { c[i] = s.charAt(t - (2 - f) - i); } else { c[i] = s.charAt(i); } } return String.valueOf(c); }}