Different First Letter

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

No. The first characters are different.

Different First Letter

Sometimes looking at the first character is enough to detect the inequality of two strings. If the first letters are different, the strings are not equal. The other characters in the strings do not matter.

Write this rule using a small letter x for the first letter of the first string, and a big letter X for the rest of the first string. The symbol + means concatenation. So the first string is x+X. (That is, the first string is its first character followed by the rest of its characters.)

Use a small letter y for the first letter of the secoond string, and a big letter Y for the rest of the second string. So the second string is y+Y. Now the rule is:

equals( x+X, y+Y ) = false if x != y

For example, equals( "mangrove", "acorn" ) is false. x is 'm' and X is "angrove". y is 'a' and Y is "corn".

QUESTION 12:

Is "fox" equal to "flypaper" ?