Get Substring Of A Given String | Java Programs

Output:

*** Substring Of String ***

String:    The quick brown fox jumps over the lazy dog.
Substring:  quick 

Click Here For Java Online Compiler

Solution:

public class Substring {

    public static void main(String[] args) {
        System.out.println("*** Substring Of String ***" + "\n");
        String string = "The quick brown fox jumps over the lazy dog.";

        // Get a substring of the above string starting from
        // index 4 and ending at index  10.
        String substring = string.substring(4, 10);

        System.out.println("String:    " + string);
        System.out.println("Substring: " + substring);
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon