I was wondering, is there any function or way, how to select from a random text all words(strings) with only uppercase letters? To be more specific, I want to take from text all uppercase words and put them into an string array, because those uppercase words are important for me.
For example from text: "This text was just made RANDOMLY to show what I MEANT."
In string array I will have words RANDOMLY
and MEANT
.
And array should looks like this String[] myArray = {"RANDOMLY", "MEANT"};
The only thing I think of is that I have go trought every single letter and check if its uppercase,
if yes
- save the letter to a string variable
- increase value of help integer variable (
int count
) by one - and take a look at the next letter,
- if its uppercase again, repeat this part
- if not - move to another letter.
I think my solotion is not very effective, so can tell me your opinion about it? Or prehaps how to make it more effective?
PS: int count
is there for expelling short words with 3 letters and less.