I try to make a multidimensional array with methods. But i stuck in here; my print method not working properly. It shows nothing and no errors.
public void bas() { // ========> print method
for (int a = 0; a < dizi.length; a++) {
for (int b = 0; b < dizi[a].length; b++) {
System.out.println(" dizi[" + n + "][" + m + "] = "
+ dizi[n][m]);
}}}
it fixed.
public int[][] doldur() { // ========> fill method
for (int i = 0; i < dizi.length; i++) {
for (int j = 0; j < dizi.length[i]; j++) { //problem in here: The type of the expression must be an array type but it resolved to int
}
}
return dizi;
}
dizi.length[i] => dizi[i].length
rest of my code:
public class ikiBoyutluDizi {
int n, m;
int[][] dizi = new int[n][m];
public int[][] diziBoyutu(int a, int b) {
return dizi;
}
public int[][] doldur() { // ========> fill method
for (int i = 0; i < dizi.length; i++) {
for (int j = 0; j < dizi.length[i]; j++) {
}
}
return dizi;
}
public void bas() { // ========> print method
for (int a = 0; a < dizi.length; a++) {
for (int b = 0; b < dizi[a].length; b++) {
System.out.println(" dizi[" + n + "][" + m + "] = "
+ dizi[n][m]);
}
}
}
public static void main(String[] args) {
ikiBoyutluDizi dizi2x = new ikiBoyutluDizi();
dizi2x.diziBoyutu(2, 3);
dizi2x.doldur();
dizi2x.bas();
}
}
One more thing; can you check my print method? Do you think is it working properly after fix the fill method?
forloops are of the same logic.