I just announced the new Spring Boot 2 material, coming in REST With Spring:

>> 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()

I just announced the new Spring Boot 2 material, coming in REST With Spring:

>> CHECK OUT THE LESSONS