0

Can somebody give me sample technique to omit one character at particular index?

For example : String s = "Hello" and int Index 3 and it output is Helo

Ankush soni
  • 1,439
  • 1
  • 15
  • 30
Rahul Das
  • 1
  • 2
  • 1
    `String result = new StringBuilder(s).deleteCharAt(3).toString();` – Suresh Atta Aug 03 '15 at 12:15
  • 1
    Learning how to fish: you go to the javadoc of the String class and you see which methods can help you achieve your goal. Takes longer maybe, but you end up realizing the existence of other useful methods that you may need in the future: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html – Gimby Aug 03 '15 at 12:18

1 Answers1

0

Utilizing the StringBuilder class:

public static String deleteCharAt(String value, int index) {
    StringBuilder result = new StringBuilder(value);
    result.deleteCharAt(index);
    return result.toString();
}
Binkan Salaryman
  • 3,008
  • 1
  • 17
  • 29