Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Arrays!

Hi Have this:
class IDMatrix {

  public static void main (String args[]) {
 
    double[][] ID;
    ID = new double[4][4];
 
    for (int row=0; row < 4; row++) {
      for (int col=0; col < 4; col++) {
        if (row != col) {
          ID[row][col]=0.0;
        }
        else {
          ID[row][col] = 1.0;
        }
      }
    }
   
  }
 
}
How do i create the html table for this??
0
archrajan
Asked:
archrajan
  • 2
1 Solution
 
CEHJCommented:
Something like:


      static void printTable() {
            double[][] ID;
            ID = new double[4][4];

            System.out.println("<TABLE>");
            for (int row = 0; row < 4; row++) {
                  System.out.println("<TR>");
                  for (int col = 0; col < 4; col++) {
                        System.out.print("<TD>");
                        if (row != col) {
                              ID[row][col] = 0.0;
                        } else {
                              ID[row][col] = 1.0;
                        }
                        System.out.print(ID[row][col]);
                        System.out.print("</TD>");

                  }
                  System.out.println("</TR>");
            }
            System.out.println("</TABLE>");
      }

0
 
archrajanAuthor Commented:
Thanks a ton for the speedy response!
fun and easy!
0
 
CEHJCommented:
:-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now