Write a method that accepts a String type array named words, a char type argument named character and prints all the strings from words array that have the given character at any location. Method header: public static void findStringsByCharacter(String[] words,char character) The method should print all the strings from words array that have the given character at any location. Main Method In the main method first you have to declare a string array of size 10, then ask the user to enter the words one by one and validate it according to the rules given below: 1. Word should not contain any special character and dot ( . ). 2. Word should contain uppercase or lowercase alphabets e.g a-z, A-Z. 3. Word should contain digits e.g 0-9. 4. If the user inputs an invalid word, your main method should prompt the user again to input a valid word. Call the above method by passing string array as parameter and a character of your choice.
Write a method that accepts a String type array named words, a char type argument named
character and prints all the strings from words array that have the given character at any
location.
Method header:
public static void findStringsByCharacter(String[] words,char character)
The method should print all the strings from words array that have the given character at any
location.
Main Method
In the main method first you have to declare a string array of size 10, then ask the user to enter
the words one by one and validate it according to the rules given below:
1. Word should not contain any special character and dot ( . ).
2. Word should contain uppercase or lowercase alphabets e.g a-z, A-Z.
3. Word should contain digits e.g 0-9.
4. If the user inputs an invalid word, your main method should prompt the user again to
input a valid word.
Call the above method by passing string array as parameter and a character of your choice.
Step by step
Solved in 2 steps with 2 images