Hi,
Id like to generate a nine-digit combinations of 52 characters of alphabet (a..z and A..Z).

My thought is:

  1. Generate nine-digit combinations of numbers from 0 to 51
  2. Use these combinations as indexes of
    char[] alp={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

Iam sure its very easy..
Im learning Java for one month (once a week), sorry for my english (:
Thank you very much for any idea

That is a good start, you now just need to generate a random number between 0 and 51, this can be achieved by:

import java.lang.Math;

int a = (int) Math.random() * 52; //Create a random number between 0 and 51

Then use the variable a as an array index.

That is a good start, you now just need to generate a random number between 0 and 51, this can be achieved by:

import java.lang.Math;

int a = (int) Math.random() * 52; //Create a random number between 0 and 51

Then use the variable a as an array index.

Thanks but I have to systematically generate combinations with no recurrence.

You could still use random, but use an ArrayList and delete the occurrence after it has been used.

You could still use random, but use an ArrayList and delete the occurrence after it has been used.

But it must generate 3679075400 nine-digit combinations.I cant get rid of characters becose I have to use it in next generated combination..but thank you anyway

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.