How to remove specific character from a string by index in Java

1 Answer

0 votes
public class MyClass {
    public static String removeCharAt(String s, int pos) {
        return s.substring(0, pos) + s.substring(pos + 1);
    }
    public static void main(String args[]) {
        String s = "Java Programming";
      
        s = removeCharAt(s, 3);
 
        System.out.println(s);
    }
}




/*
run:
 
Jav Programming
 
*/

 



answered Aug 18, 2021 by avibootz

Related questions

1 answer 159 views
1 answer 143 views
4 answers 323 views
2 answers 231 views
...