I was trying this code writing exercise and I am so lost!
The exercise is:
Complete the method which takes two Strings and one boolean as input. If the boolean is true, this method compares the first two Strings, ignoring case considerations (uppercase/lowercase). Two Strings are considered equal ignoring case if they are of the same length, and corresponding characters in the two Strings are equal ignoring case.
If the boolean is false, this method should compare two Strings and return true if the first String represents the same sequence of characters as the second String, otherwise false.
Note: compareTwoStrings("HELLO", "", false) should return false.
And here is my attempt:
public boolean compareTwoStrings (String a, String b, boolean isIgnoreCase) { if (a.equalsIgnoreCase(b)) { return (isIgnoreCase==true); } else if (a.equals(b)) { return (isIgnoreCase==false); } } It doesn't even compile, but even if it did, I'm sure it wouldn't work.