Need help writing a program for #2 in Java!
(2) Count the occurrence of a word in the string, and return this number.
int countWordsInString(String str, String word, boolean caseSensitive);
str: String -- a string which contains words
word: String -- the word to be found in "str"
caseSensitive: boolean -- do a case-sensitive comparison if true; otherwise, ignore case
return: the count number
Example:
Input String: "hello, Hello this is hEllo"
Count occurrence of word "Hello", caseSensitive: false/true
Return: 3/1