How to Compare Strings in Java
How to Compare Strings in Java
Create two String objects.
days
hours
Use boolean startsWith(String prefix) to compare the start of strings.
days
longer
Use boolean startsWith(String prefix int offset).
longer
longer
Use boolean endsWith(String prefix) to compare the end of strings.
days
longer
Use int compareTo(String anotherString) to compare two strings.
longer
longer