how to generate number and characters together randomly. I know how to generate numbers randomly, but not getting anywhere with random character generation.
If you can pick a random letter and you pick a random integer, you can pick a random letter or integer, depending on the probability distribution you want. An example:
for (int i = 0; i < stringLength; i++)
int randomNumber = /* number from 0 to 35 */
if (randomNumber < 10)
c = /* pick random digit */
c = /* pick random letter */
// add c to end of randomString
I really don't like all these hacks based on the internal representation of chars, and what about the non-alphanumeric chars that sit in spaces between the alphabetics in ASCII/Unicode? Here's a good Java way to do it:
Create a char array containing all the valid symbols you want to use (digits, upper/lower case letters, selected punctuation etc). Use your random integers as indexes into the array to select random chars.
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"