IONOS
ionos.com › digital guide › websites › web development › java substrings
How to use the Java substring method - IONOS
January 6, 2025 - If you want to extract a specific subset from the larger string, you have several options. The method Java String.split() breaks an entire string down into its individual parts to, for example, give you a clearer overview of the string. The method substring() takes that one step further and returns only the part of the string that you define.
W3Schools
w3schools.com › java › ref_string_substring.asp
Java String substring() Method
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Practice Problems Java Server Java Syllabus Java Study Plan Java Interview Q&A ... The substring() method returns a substring from the string.
Java Substring
01:11
How can you get a substring from a String? Cracking the Java Coding ...
02:06
Java String Methods Explained: length(), charAt(), substring() ...
04:47
Java Tutorial - 15 - Searching a String from the End for a Substring ...
03:12
#69 Java String contains() Method – Check if a String Has a ...
05:32
Java Strings - substring() - YouTube
Baeldung
baeldung.com › home › java › java string › java string.substring()
Java.String.substring() | Baeldung
April 11, 2025 - • Java String.substring() (current article)• Java String.toLowerCase() • Java String.toUpperCase() • Java String.trim() • Java String.valueOf() The method substring() comes with two signatures. If we pass the beginIndex and the endIndex to the method, then it obtains a part of a String given the starting index and the length of the result.
BeginnersBook
beginnersbook.com › 2013 › 12 › java-string-substring-method-example
Java String substring() Method with examples
Returns a substring starting from specified beginIndex till the character present at endIndex – 1. Thus the length of the substring is endIndex-beginIndex.
Software Testing Help
softwaretestinghelp.com › home › java › java substring() method – tutorial with examples
Java substring() Method - Tutorial With Examples
April 1, 2025 - Here, we will take an input String “Saket Saurav” and try to fetch the substring starting from the zeroth index and ending on the zeroth index. It will be interesting to see how the program responds. As we have the starting and ending indexes as the same, it should return a blank. However, the program compiles successfully in this scenario. It will return blank for all such values where the starting and ending indexes are the same. Be it (0,0) or (1,1) or (2,2) and so on.
Programiz
programiz.com › java-programming › library › string › substring
Java String substring()
Working of Java String substring() method · Note: You will get an error if · startIndex/endIndex is negative or greater than string's length · startIndex is greater than endIndex · class Main { public static void main(String[] args) { String str1 = "program"; // 1st character to the last character ·
Codecademy
codecademy.com › docs › java › strings › .substring()
Java | Strings | .substring() | Codecademy
April 28, 2025 - The .substring() method in Java returns a portion of a string from a specified starting index to an (optional) ending index.
Javatpoint
javatpoint.com › java-string-substring
Java String substring()
Java String substring() method with method signature and examples of concat, compare, touppercase, tolowercase, trim, length, equals, split, string substring in java etc.
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › String.html
String (Java Platform SE 8 ) - Oracle Help Center
July 21, 2026 - Otherwise, let k be the index of ... whose code is greater than '\u0020'. A String object is returned, representing the substring of this string that begins with the character at index k and ends with the character at index m-that is, the result of this.substring(k, ...
Vultr Docs
docs.vultr.com › java › standard-library › java › lang › String › substring
Java String substring() - Extract Substring | Vultr Docs
January 1, 2025 - Looping over a string to extract multiple substrings is a common use case, for example, parsing a formatted data string: Consider a scenario where you want to extract words separately from a string containing space-separated words: ... String sentence = "Java substring method"; String[] words = sentence.split(" "); for(String word : words) { System.out.println(word); } Explain Code
CodingBat
codingbat.com › doc › java-string-substring.html
Java Substring v2
There is a more complex version of substring() that takes both start and end index numbers: substring(int start, int end) returns a string of the chars beginning at the start index number and running up to but not including the end index.
CodingBat
codingbat.com › java › String-1
CodingBat Java String-1
String-1 chance · Basic string problems -- no loops. Use + to combine Strings, str.length() is the number of chars in a String, str.substring(i, j) extracts the substring starting at index i and running up to but not including index j. New videos: String Introduction, String Substring · Java Example Solution Code ·
Top answer 1 of 2
3
I hope you can better understand with this example:

2 of 2
2
Java's substring inputs,
public String substring(int beginIndex,int endIndex)
beginIndex - the beginning index, inclusive.
endIndex - the ending index, exclusive.
Note the exclusive. substring(0,1) will return a string including character 0, up to but NOT including character 1.
Source: http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#substring(int, int)