go to previous page   go to home page   go to next page

Answer:

Yes: the equalsIgnoreCase() method.


Equals Ignore Case

Let us modify the recursive definition of equals() so that two strings are equal if both strings are the same length, and both strings have the same letters in the same position, but upper and lower case letters are regarded as equivalent.

For example,

equalsIC( "X", "X" ) is true
equalsIC( "X", "x" ) is true
equalsIC( "X+++x", "x+++X" ) is true
equalsIC( "StingRay", "stingRAY" ) is true

This is similar to the method equalsIgnoreCase() of String objects.

  1. If StringA has no characters and StringB has no characters, then the strings equal.
  2. If StringA has no characters and StringB has some characters, then the strings equal.
  3. If StringA has some characters and StringB has no characters, then the strings equal.
  4. Otherwise,
    • convert the first character of each string to lower case.
    • if the first characters are different, then the strings equal.
    • if the first characters are the same, then the strings then the strings equal if the tails are equal ignoring case.

QUESTION 23:

Complete the definition by selecting the correct option in each drop-down list.


go to previous page   go to home page   go to next page