Remove First Letter From String Using Java

Last Updated on December 27, 2020 by Roshan Parihar

In this tutorial, learn how to remove the first letter of the string using java. The short answer is to use the Java substring() function with 1 as the argument. Java removes the first character from a string and actually generates the new string.

If you have a symbol in the string first letter, you can use the java substring function to remove it. However, the function actually does not remove character but generates a new string. The new string comes without the first letter of the old string.

How to Remove First Letter From String Using Java

To remove the first letter from the string. Use the below code that contains the old string and the new string. The old string contains the first letter as a symbol ‘&’. The new string is without the first letter ‘&’.

Output

The old string is: &My string is this.
The new string after removal is: My string is this.

The above example gives the output without the first character of the string. It prints both the old string and the new string as the output of the code given above.

However, you can change the string and the output as per your requirement. In addition to the above, you can remove more than one string characters using the java substring(). To remove more letters from the string, you have to increase the argument value you are passing to the function substring().

You May Also Like to Read

I hope you like this tutorial on how to remove the first letter of the string using java.

2 replies on “Remove First Letter From String Using Java”

  1. Please define “as an argument” in “you have to remove string as an argument in substring”. I’m sure everybody understands what you mean but it’s a little annoying when tutor sites use terms like that to explain simple things.

Comments are closed.