Write the method boolean containsRoot(String word) in Java that returns true if the string in word contains inside (see below) one of...
X1640: containsRoot(word)?
Write the method boolean containsRoot(String word) in Java that returns
true if the string in word contains inside (see below) one of these roots:
"act", "form", "port", "view"
By contains inside we mean that the word cannot start nor end with the root.
For example for the root act, the method returns true for
inactive and proactive because the root act is embedded in the
word, but it would return false for action and react because the root
act either starts the word (action) or ends the word (react).
Note that you cannot use endsWith() nor startsWith() to do the comparison.
You may consult the Java String class to help you solve this problem.
Examples:
containsRoot("inactive") -> true
containsRoot("proactive") -> true
containsRoot("action") -> false
containsRoot("react") -> false
Your Answer:
Feedback
Your feedback will appear here when you check your answer.