Java String substring() method


In this program, You will learn how to implement the String substring() method in java.


if (a.substring(b)) { 
   //statement
}

Example: How to implement the String substring() method in java.

import java.util.Scanner;

class Main {
    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String a, b;

        System.out.print("Enter string value:");
        a = sc.nextLine();

        b = a.substring(5);

        System.out.print("Substring value:" + b);

    }
}

Output:

Enter string value:Xiith.com
Substring value:.com