String API : startsWith() : Illustration

 MAIN.JAVA:

import java.util.*;
public class Main {
    public static void main(String[] args) {
        System.out.println("Enter the string");
        Scanner sc = new Scanner(System.in);
        String in = sc.nextLine();
        System.out.println("Enter the start string");
        String in1 = sc.nextLine();
        if(in.startsWith(in1)){
            System.out.println("\""+in+"\""+ " starts with "+"\""+in1+"\"");
        }else
            System.out.println("\""+in+"\""+ " does not start with "+"\""+in1+"\"");

    }
}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.