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??
LVL 25
archrajanAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.