concept endsWith in category java

appears as: endsWith
Java SE 11 Programmer I Certification Guide

This is an excerpt from Manning's book Java SE 11 Programmer I Certification Guide.

  • The method endsWith determines whether a String ends with a specified String.
  • OCA Java SE 8 Programmer I Certification Guide

    This is an excerpt from Manning's book OCA Java SE 8 Programmer I Certification Guide.

    Explanation: When it comes to the String class, it’s easy to confuse the methods that accept char or String values as method arguments. For example, the overloaded method indexOf can accept both String and char values to search for a target value in a String. The methods startsWith and endsWith accept only arguments of type String. The method charAt accepts only method arguments of type int. Hence, this method can be passed char values, which are stored as unsigned integer values.

    You learned how a char array is used to store the value of a String object. This helps explain why the methods charAt(), indexOf(), and substring() search for the first character of a String at position 0, not position 1. We also reviewed the methods replace(), trim(), and substring(), which seem to modify the value of a String but will never be able to do so because String objects are immutable. You also learned the methods length(), startsWith(), and endsWith().