0

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

2
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by d8m9
0

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.

Edited by joehms22: n/a

0

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.

0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.