This is the code for the random Password generator I am trying to write. If anybody runs this code, they will see the problems I am having. Can somebody please help me see what is wrong with this code? Thanks in advance.
We're glad you're here, and folks are delighted to help. However, there are some things you can do to make life easier for others to help you.
Please take a few minutes and browse around this page. It will give you some tips on the best way to present your problem.
One of which is to actually tell other what the problem is. If you say "I was expecting A, but got B", often someone can skim your code and focus in on the problem. A lot of folks will read your post and say "Too much work to do all that, I'll skip it and move on".
The other main thing is to please use the 'code' tags. there are little buttons that you can use to insert special 'tags' that you then paste your code between. This preserves the formatting and makes it much easier to read.
I'll try and edit your post to have those, but if you could please post exactly what your problem is, you're more likely to get the help you need.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
When java sees something like "firstChar + secondChar + thirdChar" it says
"hmm... what are these things on either side of the '+' character?"
In this case, they are char variables, which java believes are actually numeric values. What does it mean to add two numeric values? you calculate the sum. So, I would expect you are calculating some big sum and printing garbage.
The suggested solution is a little different. Java sees the firs thing is a String (albeit an empty one). It then says "how do I add a String and a number?" The answer is it converts the number to a string, then concatenates them together. if you have a whole series (as in your case), it figures out what to do with the first pair. Then, it takes the result of that (which is a String), and figures it out all over again with the next value, and keeps working its way down the list.