If I understand the question correctly, then you do not have a matrix, but the same number of values, which is specified because your cycle works i the number of times, so that the matrix would be necessary to pass the square of the required value in the cycle condition. Your option:
i = Integer.parseInt(elemNumbers.getText()); int count = 0; while (count < i) {
those. if i = 5 it will work 5 times. here it is necessary either before the condition of the cycle to multiply the transmitted number by i * = i; those.:
i = Integer.parseInt(elemNumbers.getText()); int count = 0; i *= i; while (count < i) {
either implemented in 2 cycles:
class example { int count; private void massiveGet() { count = Integer.parseInt(elemNumbers.getText()); for (int i = 0; i < count; i++) { for(int k = 0; k < count; k++){ int number = (int) (Math.random() * 100); matrixData.add(new Massive(number)); } //Здесь можно организовать перенос строки в матрице } System.out.println(matrixData); } }
In my opinion, the second option is more convenient, from the point of view that, if necessary, you can reset certain values during a "line break".
Massiveclass? Why does his constructor accept only one number? - diraria