View Single Post
  #1 (permalink)  
Old 02-11-2008, 06:17 AM
cloudkicker cloudkicker is offline
Member
 
Join Date: Feb 2008
Posts: 1
cloudkicker is on a distinguished road
Would appreciate your help with 2d Array..
Hello Everyone,

I am new to Java and new to Java Forums. I would really appreciate it if someone can help me understand how I can do this task. I am learning java via online tutorials and couple of books. What I want to do is to populate a multidimensional array's elements with another arrays elements such as:

I declare two arrays:

1. moon[][] is multidimensional array
2. m in a array with assigned elements

I would like to take elements of Array m and assign them to the rows of the moon and then take the Array m elements again and multiply them by 3 and then assign them to the columns of Array moon. Any help would highly be appreciated .

Thank you.

PHP Code:

public class 2dArray
{

          public static 
void mainString args[] )
     {


      
int[][] moon = new int [10][4];
      
int[] = {123456};

      for (
int j=0m.lengthj++)
         {
            
moon[j][j*3] = m[j];   //  THIS IS WHERE I AM HAVING AN ISSUE
            
System.out.println(moon[j][j] + " " );
          }

            
System.out.println();

             
// print array in rectangular form

             
for (int r=0moon.lengthr++)
             {
                 for (
int c=0moon[r].lengthc++)
                 {
                     
System.out.print(" " moon[r][c]);
                 }
                 
System.out.println(" ");
             }

      }



Last edited by cloudkicker : 02-11-2008 at 06:36 AM.
Reply With Quote
Sponsored Links