troubleshooting Question

Getting a two dimension array of strings from another class.

Avatar of taborrg
taborrg asked on
Java
27 Comments1 Solution423 ViewsLast Modified:
Hi,

The two dimensional array works OK from one class.

From class Oracle,

public static String strLine[]= new String[11]; // 11 fields - first, middle, last name, etc.
public static String[][] arryMain= new String[5][5]; // hold array of strLines
   // I can print out both records OK.
 
public static String[][] getArryMain(){
            return arryMain;
}


Getting the two dimensional array from another class,

      
            String[][] newLine = Oracle.getArryMain();
            for (int j=0;j<2; j++)  // There are only two records in this example
            {
                  System.out.print("Record Number: ");
                  System.out.println(j);
                  for (int k=0;k<11; k++)
                  {
                        System.out.println(newLine[j][k]);
                   }
            }
            
Record Number: 0
hi
M
Carver
33 Richards Street
Honolulu
...

Record Number: 1
hi
M
Carver
33 Richards Street
Honolulu
...

This show that both records have the same information.  The last record gets placed
in both positions.

Thanks.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 27 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 27 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros