涉及数组的面向对象编程

Object Oriented Programming Involving Arrays

我对这个问题很迷茫,我什至不知道如何到达终点。我什至无法让我的阵列工作。有人可以帮我吗?

Problem #73-Write a method with a void return value that sets to 0 all the elements of the even numbered rows and sets to 1 all the elements in the odd numbered rows of a 2-dimensional array of ints. Include the code to test your method.

public class EvenOdd
{



   /*public EvenOdd(int numberOfRows, int numberOfColumns)
   {
  oddOrEven = new int [numberOfRows][numberOfColumns]; 
  }//end arrayEvenOdd
*/
   public static void main (String []args)
{
  int [][] oddOrEven = { {1,2,3} , {1,3,5} };

  for (int i = 0; i < oddOrEven.length; i++)
  {
  if (oddOrEven[i] % 2 == 0)
  {
     for(int j = 0; j < oddOrEven[i].length; j++)
     {
        oddOrEven[i][j] = 0;

     }//end loop
     System.out.print(oddOrEven[i]);
  }//end set loop

  else 
  {
     for(int j = 0; j < oddOrEven[i].length; j++)
     {
        oddOrEven[i][j] = 1;
     }
     System.out.print(oddOrEven[i]);  
  }
  }
  }
}//end class

尝试替换

if (oddOrEven[i] % 2 == 0)

if (i % 2 == 0)