samedi 7 novembre 2015

Array value to string function

So basically I need to make a hash table, I understand how to do it with a string array but I need to do so with a random array I make.

Basically here is my random number code that another user gave me

    int[] array = new int[8000];
    Random rng = new Random();
    for (int i = 0; i < 8000; i++) {
    array[i] = rng.nextInt(65536);  
    }

I need this to somehow turn into something like this in my professor's example code

String[] array = { "100", "510", "170", "214", "268", "398",
            "235", "802", "900", "723", "699", "1", "16", "999", "890",
            "725", "998", "978", "988", "990", "989", "984", "320", "321",
            "400", "415", "450", "50", "660", "624" };

Which i tried and did this:

 int[] array = new int[8000];
 Random rng = new Random();
 for (int i = 0; i < 8000; i++) {
     array[i] = rng.nextInt(65536);
     String strI = Integer.toString(i);
     String[] array = {i + "," };

}




Aucun commentaire:

Enregistrer un commentaire