I need to take a phrase that contains a specific word, then if it does have that word even if it's part of another word, to print the entire word out.
I think how to find the word "apple"
, but I can't figure how to find the word "appletree"
.
So far, I have some code that finds the word apple and prints that out.
String phrase = "She's sitting under an appletree!";
if (phrase.contains("apple")) {
System.out.println("apple");
} else {
System.out.println("none");
}
How do I print "appletree"
?