mardi 29 novembre 2016

Once I've generated a random Int between a range, how could I assign that integer to each letter in the alphabet?

New to arrays here... I want to get a random integer and set that integer to each individual letter in the alphabet like integer 1 = a. So that I can print a random letter in the alphabet without using a pre-existing java method for random string. I don't want to generate a random string this is the way I need it.

{
  public static void main(String[] args)
  {
    Random Gen = new Random();

    String[] letters = new String[50];

    String alphabet = "abcdefghijklmnopqrstuvwxyz";

    int randomInt = Gene.nextInt(26);

    String second = "" + randomInt;
    System.out.println(second);

    //Not sure what next....
  }
}




Aucun commentaire:

Enregistrer un commentaire