Java – Remove first character in string

To remove the first character in given string in Java, you can use the String.substring() method. Call substring() method on the given string, and pass the start index of 1 as argument. The method returns a substring from second character (index=1) to the end of the given string.

If str is given string, then the expression to get a resulting string with the first character removed from the string is

str.substring(1)

1. Remove first character from string using String.substring() in Java

In this example, we take a string "Apple" in str and remove the first character in the string using String.substring() method.

Java Program

public class Main {
	public static void main(String[] args) {
		String str = "Apple";
        
		// Remove first character
		String resultString = str.substring(1);
		System.out.println(resultString);
	}
}

Output

pple
ADVERTISEMENT

Conclusion

In this Java String tutorial, we have seen how to remove the first character in a given string in Java using String.substring() method, with examples.