arrays - How to use variable from class inside method in java -


so have write minesweeper game assignment. if made class board, containing 2 2d-arrays, 1 board value , 1 holding whether user had clicked there or not clicked. wrote methods arguments of 2 2d-arrays. how call arrays in main class?

public class board {      int x;     int y;     public char[][] board;     public char[][] reveal;      board(int x, int y){         board = new char[x][y];         reveal = new boolean[x][y]; }      }  public class mine{      public static void main(string[] args){          board gameboard;         gameboard = new board(5, 5);                     ???          board.printboard(board, reveal);      } }   public void printboard(char[][] board, boolean[][] test){          for(int i=0; i<=board.length; i+=1){             for(int j=0; j<board[i].length; j+=1){                 if (test[i][j]==true){                 system.out.print(board[i][j]);                 }                 else {                     system.out.print('?');                 }             }             system.out.println();         }      } 

how call arrays in main class?

you don't 'call' array. call methods. if want access instance variable of class, need provide accessor methods, i.e. methods 'get' , 'set' instance variable.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -