Advanced Java questions -4
A program which will accept three sentences (one sentence per line) and print the words having Initial Caps within the sentences. Below is an example.
Here is an example. If the below three sentences are given to the program as input,
This is a Program
Coding test of Initial Caps
the program Will Test You
Then, the output would look like:
This
Program
Coding
Initial
Caps
Will
Test
You
Solution:
Pattern p = Pattern.compile("^[A-Z]");
Here is an example. If the below three sentences are given to the program as input,
This is a Program
Coding test of Initial Caps
the program Will Test You
Then, the output would look like:
This
Program
Coding
Initial
Caps
Will
Test
You
Solution:
Pattern p = Pattern.compile("^[A-Z]");
Comments
My Name is Harry
Helloo how aRe yOU
What u DoINg
the result is
My
Name
Harry
Helloo
aRe
yOU
What
DoNIg
But according the question only words with intial caps sholud be displayed in output but aRe is not having intial caps as a is small
I think you are wrong. because output is:
My
Name
Harry
Helloo
What
DoINg