This program checks if a given string starts with a specified substring. Here's a brief explanation of the code:
public class Check_Startswith { public static void main(String[] args) { String str1 = "Orange is Favorite Fruits"; String str2 = "Grapes is also my favorite Fruits"; String start = "Grapes"; boolean s1 = str1.startsWith(start); boolean s2 = str2.startsWith(start); System.out.println("\""+str1 + "\" starts with \"" +start + "\" ? " + s1); System.out.println("\""+str2 + "\" starts with \"" +start + "\" ? " + s2); } }
"Orange is Favorite Fruits" starts with "Grapes" ? false "Grapes is also my favorite Fruits" starts with "Grapes" ? true
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions