Removing the first character from a string in Java

Removing the first character from a string in Java

In this post we will give you information about Removing the first character from a string in Java. Hear we will give you detail about Removing the first character from a string in JavaAnd how to use it also give you demo for it if it is necessary.

we are going to learn about how to remove the first character from a string in Java.

Removing the first character

To remove the first character from a string, we can use the built-in substring() method in Java.

Here is an example, that removes the first character h from the following string.

String str = "hello";String result = str.substring(1);System.out.println(str.substring(1));

Output:

ello

In the example above, we have passed 1 as argument to the substring() method. so it begins the extraction at index position 1 and extracts to the end of a string.

Note: The substring() method doesn’t mutates the original string, instead of it creates a new one with the extracted characters.

Further Reading

Hope this code and post will helped you for implement Removing the first character from a string in Java. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US