From the String array, you need to output a word in which a certain letter is hidden in the maximum number of times.
For example, givenString [] words ={"black","one","doodle","snack","divine"};
String let = "d"; The program should display the word doodle
My code is:
public static void main(String[] args) { String let = "d"; String [] words ={"black","one","doodle","snack","divine"}; for (int i = 0; i <words.length; i++) { if (words[i].contains(let)) { System.out.println(words[i]); } } } I can print the words in which the letter is found, but how can I output the word with the maximum repetition of the letter?