.
.
you
with
be
force
the
May
.This is caused by recursion. The program starts by running the stackWords method and accepting the first word entered, being “May”. The String variable word is assigned the value of “May”. Because word isn’t equal to “.”, a second stackWords method is began before the first reaches its end. This second stackWords method has its own local variable word, equal to “the”. Again, “the” isn’t equal to “.”, and a third stackWords method is run before the second (or first) can end. This continues until the value “.” is assigned to a word variable. At this point, the seventh stackWords method is required to write the value of word in the Terminal window, then end. The program can then advance to the sixth stackWords method and do the same thing; however, the value of word for this stackWords is different from that of the seventh. Thus, the phrase “May the force be with you.” is repeated backwards. Finally, after the first stackWords method ends, the program does as well.
.
−Phoenix
Indeed. 900 XPs awarded for this completion.
ReplyDelete