Would greatly appreciate if someone could help me out, I think there is a problem in the main method of my code.
The array should display in the console and any rows or columns in the array should be set to zero if there is a zero in the row or column.
I know it is something small but I cannot figure it out and it keeps terminating when I run it.
Thanks in advance.
package array;
public class array {
private int array[][]= {{0,1,2,5},{4,5,6,7},{8,9,0,3}};
private int newArray[][]= {{0,1,2,5},{4,5,6,7},{8,9,0,3}};
private int row;
private int column;
public void zeroise (int[][] array){
outputArray();
}
public static void main(String[] args) {
array newArray = new array();
newArray.zeroise(null);
}
public void outputArray() {
for(int i = 0; i<array.length; i++)
{
for(int j = 0; j<array.length; j++)
{
if(array [i][j]==0)
{
row=i;
column=j;
makeZero();
}
}
}
}
private void makeZero() {
for(int i = 0; i < newArray.length; i++) {
newArray[row][i]=0;
}
{
for(int j = 0; j < newArray.length; j++){
newArray[j][column]=0;
}
}
}
public int [][] printarray()
{
return array;
}
public int [][] printnewArray()
{
return newArray;
}
}

New Topic/Question
Reply



MultiQuote



|