Many people won't click on external links so it's generally better to post the relevant sections of code in the post (remembering to UseCodeTags (← click))
There is something wrong when you have that many levels of indentation. Google for Arrow AntiPattern. The code looks like an arrowhead and the many levels of indentation suggest there is something wrong. One thing wrong is the break; statement not wrapped in an if. I don't like break; at the best of times but if it isn't wrapped in an if then I am sure it is an error. Even without reading the rest of the code.
There is also something wrong with those long lines; they are difficult to read. I have broken them so you can see how to do it correctly, and got rid of some unnecessary empty lines.
Well it took a little longer than I expected but I eventually got the output. The thing is you have to spend some time with a pencil and paper.
I'm not going to post the solution here (because you're not supposed to! :p) but if you're interested in knowing how I solved the problem you can contact me at: [email protected]
Google Arrow AntiPattern? Really? A "Beginning Java" question and the response is to Google a pattern? If I were to venture a guess I'd say most beginners don't know what patterns are.
How about suggesting that math can be performed on a char or that an alphabet array isn't necessary? Break statements not inside if blocks is not necessarily wrong just because you don't like them. Breaks are completely legit in switch blocks.
Of course, the real question that needs to be asked of the OP is what are the requirements of the program? An example of some output has been provided, but what are the requirements? I can create multiple ways for creating the desired output but they are meaningless without the requirements.
Emil Jennings wrote:Campbell what happened to helpful responses?
Google Arrow AntiPattern? Really? A "Beginning Java" question and the response is to Google a pattern? If I were to venture a guess I'd say most beginners don't know what patterns are.
Easy there, cowboy. Even if the OP didn't know what patterns are, Googling for and learning about Arrow code isn't going to hurt them.
Emil Jennings wrote:How about suggesting that ...
Again, please be careful with the way you phrase things; this comes across with a cynical tone.
In the future, try for something less snarky to make your point(s), something like the following would have come across better and more in line with the "be nice" policy we follow around here:
Out of curiosity, I looked up the Arrow code anti-pattern and I'm not sure the OP is at a place where that's going to help him/her right away. Also, I think there are valid uses for break and giving more technical reasons for avoiding them might be more useful. For instance, breaks are actually necessary in switch case statements and sometimes they come in handy in loops. These could lead us to discussions that digress from the original question though so maybe we can go there later.
Right now, it would more helpful if the OP told us what are the requirements of the program. An example of some output has been provided, but what are the requirements? I can create multiple ways for creating the desired output but they are meaningless without the requirements.