Java Top

I just announced the new Learn Spring course, focused on the fundamentals of Spring 5 and Spring Boot 2:

>> CHECK OUT THE COURSE

The method startsWith() is a convenience method that checks whether a String starts with another String. We can also pass the index of the first character to start checking from.

Available Signatures

public boolean startsWith(String prefix)
public boolean startsWith(String prefix, int toffset)

Example

@Test
public void whenCallStartsWith_thenCorrect() {
    String str = "foo";
    
    assertTrue(str.startsWith("f"));
    assertTrue(str.startsWith("oo", 1));
}
Next »
Java String.subSequence()
« Previous
Java String.split()
Java bottom

I just announced the new Learn Spring course, focused on the fundamentals of Spring 5 and Spring Boot 2:

>> CHECK OUT THE COURSE
Comments are closed on this article!