fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int i=6;
  13. int j=6;
  14.  
  15. //initialize the array
  16. char[][] gameSpace;
  17. gameSpace = gameSpaceInitial(i, j);
  18.  
  19. //display the initial game space
  20. DisplayGameSpace(gameSpace);
  21. }
  22.  
  23. static void DisplayGameSpace(char[][] gameSpace) {
  24. for (int row = 0; row < gameSpace.length; row++) {
  25. for (int col = 0; col < gameSpace[row].length; col++) {
  26. System.out.print(gameSpace[row][col]);
  27. }
  28. System.out.println();
  29. }
  30. }
  31.  
  32. //the intial game board without any pieces
  33. static char[][] gameSpaceInitial(int maxRows,int maxColumns){
  34.  
  35. char[][] emptyBoard = new char[maxRows][maxColumns];
  36.  
  37. for (int row = 0; row < maxRows; row++) {
  38. for (int col = 0; col < maxColumns; col++) {
  39. emptyBoard[row][col] = '.';
  40. }
  41. }
  42.  
  43. return emptyBoard;
  44. }
  45. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
......
......
......
......
......
......