endsWith() returns True if a string ends with a specified substring.
public static boolean endsWith(String s1, String s2) {
boolean result = s2.endsWith(s1);
return result;
}
Function Call | Return Value | |||
---|---|---|---|---|
endsWith("o", "Hello") | → | |||
endsWith("ll", "Hello") | → | |||
endsWith("llo", "Hello") | → | |||
endsWith("5", "525") | → | |||
endsWith("52", "525") | → | |||
endsWith("25", "525") | → | |||
endsWith("g", "Egg") | → | |||
endsWith("", "World") | → | |||
endsWith(" ", "Hello World ") | → | |||
endsWith(" ", "HelloWorld") | → |
Experiment with this code on Gitpod.io