Back To Java String Class Index
//program to demonstrate startswith method of String class public class stringstartswith { public static void main(String[] args) { String ob=new String("abcdef"); boolean result; result=ob.startsWith("ab"); if(result==true) { System.out.println("string starts with ab"); } else { System.out.println("string does not starts with ab"); } } }