Absolutely, we're here to help. We don't like to hand out code, though -- we like to help you figure it out for yourself. So my first question to you is, what do you have so far? If it's nothing, then what are your thoughts about what to do first?
First one is just to read line, break it into words, and put each word in array. Than just check each word weather its first letter belongs to a set of Capital letters. I had text how to compare sets somewhere so I would still need to separate words and create dynamic array or something like that (because number of words in line is unknown)
Another idea is to create cycle that scans one letter and if it's capital than prints it and keeps on scanning and printing symbol by symbol until it reaches space. After that again, scans one letter and checks weather it's capital or not and so on... I prefer this solution and have an idea how to write a cycle but have no idea how to scan one character in java if it's possible at all...
Joined: Feb 22, 2009
Get the ascii values of the characters and check them against the ascii table.
author and iconoclast
Ryan Beckett wrote:Get the ascii values of the characters and check them against the ascii table.
No, please don't do this! First of all, Java doesn't use ASCII, but Unicode; your "capital letters" could be in many different alphabets around the world, not just ASCII. Secondly, the Java libraries provide methods to do these kinds of tests correctly for Unicode. Look at the static method isUpperCase in the java.lang.Character class.
Joined: Mar 22, 2009
Guys, I might have something here...
It works for me perfectly.
what do you think?
Joined: Feb 22, 2009
Never thought about that, and to think they teach us that in college. Thanks.
Joined: Oct 13, 2005
You may find a Scanner easier to use than BufferedReader, assuming the file is a text file.
You may find the split method of the java.lang.String class useful, too.
Joined: Mar 07, 2009
Arthur do you know what "regular expressions" are? If you don't have a look at: