Java Basics Examples
Java Tutorial
Java Useful Resources
Selected Reading
© 2013 TutorialsPoint.COM
|
Java Examples - Deleting a character
Advertisements
Problem Description:
How to remove a particular character from a string ?
Solution:
Following example shows hoe to remove a character from a particular position from a string with the help of removeCharAt(string,position) method.
public class Main {
public static void main(String args[]) {
String str = "this is Java";
System.out.println(removeCharAt(str, 3));
}
public static String removeCharAt(String s, int pos) {
return s.substring(0, pos) + s.substring(pos + 1);
}
}
|
Result:
The above code sample will produce the following result.
Advertisements
|
|
|