EN
Java - remove first character from string
0
points
In this article, we would like to show you how to remove the first character from the string in Java.
1. Using String substring() method
In the example below, we use the String substring(int beginIndex)
method, where we assign 1 to beginIndex, so we get a string without the first character.
public class StringExample {
public static void main(String[] args) {
String text = "ABCD";
String substring = text.substring(1);
System.out.println(substring); // BCD
}
}
Output:
BCD