What We Are Learn On This Post
How to Find the Starting Character Of a String Using startsWith() In Java?
package com.softwaretestingblog.programs; public class StringStarts_with { public static void main(String[] args) { // TODO Auto-generated method stub String str = "This is an example string."; System.out.println("Is this string starts with \"This\"? "+str.startsWith("This")); } }
Read Also: Find Second Highest Number In An Array
Output:
Is this string starts with "This"? true Is this string starts with "is"? false Is this string starts with "is" after index 5? true
Leave a Reply