The method endsWith() is a convenience method that checks if a String ends with another given String. If the argument is an empty String, then the method returns true.

Available Signatures

public boolean endsWith(String suffix)

Example

@Test
public void whenCallEndsWith_thenCorrect() {
    String s1 = "test";
    
    assertTrue(s1.endsWith("t"));
}
Next »
Java String.format()
« Previous
Java String.copyValueOf()
Course – LS – All

Get started with Spring and Spring Boot, through the Learn Spring course:

>> CHECK OUT THE COURSE
res – REST with Spring (eBook) (everywhere)
Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.