Re: Learning Arrays
From: Andrew Thompson (SeeMySites_at_www.invalid)
Date: 11/28/04
- Previous message: Jo Campbell: "Learning Arrays"
- In reply to: Jo Campbell: "Learning Arrays"
- Next in thread: ExGuardianReader: "Re: Learning Arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 28 Nov 2004 01:47:28 GMT
On Sun, 28 Nov 2004 01:29:49 GMT, Jo Campbell wrote:
> Hi, I am just learning arrays and I am trying to get this 2D array to print
> out like this:
>
> 0 1 2 3 4 5 6
> 0 1 2 3 4 5 6
<sscce>
import javax.swing.*;
public class array5by7{
public static void main (String args[]){
String outputString = "";
int table[][] = new int [5][7];
for (int row=0; row<table.length; row++)
{
for (int col = 0; col <table[row].length; col++)
table[row][col] = 0 + col;
}
for (int row=0; row<table.length; row++)
{
for (int col = 0; col<table[row].length; col++) {
outputString += (table[row][col] + " ");
}
outputString += "\n";
}
JOptionPane.showMessageDialog (null, outputString + "\n");
}
}
</sscce>
HTH
-- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane
- Previous message: Jo Campbell: "Learning Arrays"
- In reply to: Jo Campbell: "Learning Arrays"
- Next in thread: ExGuardianReader: "Re: Learning Arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]