Print Even length words within a String
Program : Print even length words within String using Java
public class EvenCharacterWords {
public static void printEvenWords(String s)
{
for (String word : s.split(" ")){
if (word .length() % 2 == 0)
System.out.println(word);
}
}
public static void main(String[] args)
{
String str = "Hello Welcome To Ksamyatam Softwares Coding World";
System.out.println("The given string is: " + "\n" + str);
System.out.println("\n" + "Even length words in givem string are : ");
printEvenWords(str);
}
}
The given string is:
Hello Welcome To Ksamyatam Softwares Coding World
Even length words in givem string are :
To
Coding