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]");


Comments

Anonymous said…
This code works fine but if i input
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
@Anonymous

I think you are wrong. because output is:

My
Name
Harry
Helloo
What
DoINg

Popular posts from this blog

XSLT - Modify Date and DateTime value

Integrate With Mutual Certificate Authentication based Service

Yield Price Sri Lanka - Android Application