1 Replies - 1500 Views - Last Post: 13 October 2012 - 03:23 AM Rate Topic: -----

#1 Sheldor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 24-September 12

Problem in main method, terminating when I run it!

Posted 13 October 2012 - 03:17 AM

Hi all.
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;
		}
}



Is This A Good Question/Topic? 0
  • +

Replies To: Problem in main method, terminating when I run it!

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2153
  • View blog
  • Posts: 3,315
  • Joined: 21-June 11

Re: Problem in main method, terminating when I run it!

Posted 13 October 2012 - 03:23 AM

None of your methods contain any code that would print anything. To print stuff to the screen, you can use the methods System.out.println or System.out.print.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1