Checking the Start of a String : String Start End « Data Type « Java Tutorial






public class MainClass {

  public static void main(String[] arg) {
    
    String string1 = "abcde";
    if(string1.startsWith("ab")) {
      System.out.println("starts with ab");
    }
  }
}
starts with ab








2.20.String Start End
2.20.1.Checking the Start of a String
2.20.2.Checking the End of a String
2.20.3.Accessing String Characters
2.20.4.Chop i characters off the end of a string.
2.20.5.Removes separator from the end of str if it's there, otherwise leave it alone.
2.20.6.Remove the last character from a String.