Non-Empty Strings

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.

Non-Empty Strings

The empty string "" is not equal to "grape". And "grape" is not equal to "". The empty string is not equal to any non-empty string.

A compact way of writing this rules is to use a symbol X to stand for the string of characters under consideration. Then:

equals( "", X )    = false if X is not the empty string

equals( X, "" )    = false if X is not the empty string

For example, equals( "", "hound") is false. In this example, X stands for "hound".

Also, equals( "poet", "") is false. This time, X stands for "poet".

QUESTION 11:

Is the string "walnut" equal to the string "zebra" ?

How many letters of the strings do you need to compare?