Remove the first 3 characters of a string in Java
In this post we will give you information about Remove the first 3 characters of a string in Java. Hear we will give you detail about Remove the first 3 characters of 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 3 characters of a string in Java.
Remove the first 3 characters
To remove the first 3 characters of a string, we can use the built-in substring() method by passing the 3 as a argument to it.
Here is an example:
String str = "123Hello";String result = str.substring(3);System.out.println(result);
Output:
"Hello"
In the example above, we have passed the 3 as argument to the substring() method. so it begins the extraction at index position 3 and extracts to the end of a string.
Syntax of substring() method
substring(startindex, stopindex)
It begins the extraction at startIndex and goes upto the stopindex-1, if we don’t provide the endIndex it begins the extraction at specified index extracts upto to the end of a string.
The substring() method doesn’t mutates the original string, instead of it creates a new one with the extracted characters.
Hope this code and post will helped you for implement Remove the first 3 characters of 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