Computer Science, asked by ayuygbp2020, 5 hours ago

Write a program in Java to ask the user to enter any sentence and print only those words of the sentence that have even number of letters.​

Answers

Answered by adeebahmed069
0

Take the string

Break the string into words with the help of split() method in String class. It takes the string by which the sentence is to be broken. So here ” “(space) is passed as the parameter. As a result, the words of the string are split and returned as a string arrayString[] words = str.split(" ");

Traverse each word in the string array returned with the help of Foreach loop in Java.

Similar questions