I want to number the row and column . I get row number right around the left hand side ..I want the column number on the top..This is the code I have ..CAN PLLZZ HELP ME WID the column number plzz..

    int[][] Board = new int[15][15];
    for(int j=0;j<Board.length;j++)
     System.out.print(" "+j+"  ");
    for (int r = 0; r < Board.length; r++) {

        System.out.print("\n"+r);
        for (int c = 0; c < Board[r].length; c++) {

            System.out.print("__" + " ");

        }
        System.out.println();

    }

One easy way to do this is as below.

int[][] Board = new int[15][15];
 for (int j = 0; j < Board.length; j++) {
  System.out.print((j < 10) ? " " + j + "\t" : j + "\t");} //use tab (\t) to introduce space with constant width. 
 for (int r = 0; r < Board.length; r++) {
  if (r != 0) {
   System.out.print((r < 10) ? "\n " + r : "\n" + r);
   } else {continue;}
 for (int c = 0; c < Board[r].length - 1; c++) {
  System.out.print("\t__");}
  System.out.println();
}

Alternatively you could read about formatted printing.
Hope this helps.

Why there are 3 loops??? Also, the curry brackets are not correct either...

You should not post the code right way but rather tell them the algorithm or idea. Unless it is unclear, you could give some sample codes.

@kekkaishi
Sorry for the previous post. I didn't understand the output. Anyway, please do not just post the solution right away but rather explain it to the person.

@Kekkaishi
this works but 0 is showing only one time...da 0 should show for both row and column...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.