java.lang.String substring method returns a substring of the original string based on the specified start and end index. The start index is inclusive, and the end index is exclusive.
Example 1: Get the first three characters of a string
String str = "The quick brown fox jumps over the lazy dog"; String newStr = str.substring(str.indexOf("fox"), str.indexOf("dog")); System.out.println(newStr); // output: "fox jumps over the lazy"
The java.lang package library contains the String class, which includes the substring method.
Java String.substring - 30 examples found. These are the top rated real world Java examples of java.lang.String.substring extracted from open source projects. You can rate examples to help us improve the quality of examples.