For example, a user input a number of country into a queue such as Iceland, Italy, Spain,Switzerland and Singapore . How do I compute the total number of country name that begins with the same letter?
The outcome should be
Total number of countries start with I : 2
Total number of countries start with S : 3
It is definitely wise to start with Campbell and Liutauras's advice to break this problem down into tasks, then code each task in its own method. If you were doing this by hand, how would you summarize the broad steps? For example, if I were to try to encode my process of responding to this post, I might have methods that look like...
Then my main() method looks like this...
I know I'm over-explaining this, but it's a good practice start with this type of logical breakdown.
By the way, I illustrated this using Java code, but it is far more important that you do this kind of breakdown on paper, before you start coding.
Then, once you've figured out the logic on paper, you can try encoding each method, one step at a time. What I'm responding to (and maybe Campbell and Liutauras feel similarly) is that there are a number of issues with your draft code, starting all the way back at line 10 (or even earlier if you're missing necessary import statements). Once you've broken this down, you can get help on each piece.