1// how to remove particular character from string
2public class RemoveParticularCharacter
3{
4 public static void main(String[] args)
5 {
6 String strInput = "Hello world java";
7 System.out.println(removeCharacter(strInput, 6));
8 }
9 public static String removeCharacter(String strRemove, int r)
10 {
11 return strRemove.substring(0, r) + strRemove.substring(r + 1);
12 }
13}
1// remove last character from string in java
2public class SubstringDemo
3{
4 public static void main(String[] args)
5 {
6 String strInput = "Flower Brackets!";
7 String strOutput = strInput.substring(0, strInput.length() - 1);
8 System.out.println(strOutput);
9 }
10}
1String str = "abcdDCBA123";
2String strNew = str.replace("a", ""); // strNew is 'bcdDCBA123'
1# subString(int start, int end);
2
3String a = "Hello!";
4b = a.subString(0,a.length()-1) #Remove the last String
5# b should be "Hello" then
1
2String str = "abcdDCBA123";
3String strNew = str.replace("a", ""); // strNew is 'bcdDCBA123'
4
1// Java remove character from string
2public class RemoveOnlyLetters
3{
4 public static void main(String[] args)
5 {
6 String strExample = "jd15352kLJJD55185716kdkLJJJ";
7 System.out.println("Before: " + strExample);
8 strExample = strExample.replaceAll("[a-zA-Z]", "");
9 System.out.println("After: " + strExample);
10 }
11}