Java – string prefix match using startsWith

Java String startsWith(String prefix) example:

public class Main {
  public static void main(String[] args) {
    String bigStr = "Hello World";
    String prefix = "Hello W";
    System.out.println(bigStr.startsWith(prefix));
  }
}
OpenJDK 64-Bit Server VM warning: Insufficient space for shared memory file:
   7993
Try using the -Djava.io.tmpdir= option to select an alternate temp location.


To specify offset use

startsWith(String prefix, int toffset)
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments