Write a program to find the words ends with letter 's' in a given sentence.
Input (String) | Output (List) |
---|---|
property searches and information on real estate classes | [searches, classes] |
I like my brother | [] |
Sun rises in the east | [rises] |
Learn Java with Merit Campus | [Campus] |
class FindWordsEndingWithLetterS
{ public static void main(String s[])
{
String sentence = "There are many ways to get the answers";
System.out.println("The words which ending with s are : " + getWordsEndingWithLetterS(sentence));
}
public static List<String> getWordsEndingWithLetterS(String sentence) {
List<String> result = new ArrayList<String>();
//Write a code here to get the words ending with 's' and add it to result.
return result;
}
}
Topic: Java ArrayList