lundi 11 novembre 2019

Java Array Random

String[] dizi_paragraf = dosya.split("\n");
for (int i = 0; i < dizi_paragraf.length; i++) {
     String[] dizi_cumle = dizi_paragraf[i].split("\\.");
     String[][] dizi_total = new String[dizi_paragraf.length][dizi_cumle.length];
     int[][] dizi = new int[dizi_paragraf.length][dizi_cumle.length];
     for (int j = 0; j < dizi_cumle.length; j++) {
           dizi_total[i][j] = dizi_cumle[j];
           dizi[i][j] = j;
           System.out.println(dizi[i][j]);
                                         }
}
    Output:
0-0
0-1
1-0
1-1
1-2
2-0
3-0
3-1
4-0
4-1
5-0
5-1
5-2
5-3

I want to this;

    0-1
    0-0
    1-1
    1-0
    1-2
    2-0
    3-1
    3-0
    4-0
    4-1
    5-3
    5-1
    5-0
    5-2

This is an example. The value in j for each i changes randomly but until j length. How can i do this? Have you any ideas? For example, it should produce 0 or 1 for index 0. It should produce 0.1 or 2 for the 1st index. 2. You should take only 0 for indis. ect. Just example. This can be change. I take this dynamically.




Aucun commentaire:

Enregistrer un commentaire