Trying to create a 2d array based on given rows from user input (java) -


so have far.

public static int[][] generaterandompositions(int number, int width, int height){      for(int j=0; j <number; j++){          int[][] pos = new int[][]{              {utility.randomint(width),utility.randomint(height)}           };      }      return [][]pos; } 

basically method gets number number of rows there should , width , height 2 numbers in 2 columns. of randomly generated between number given (ex utility.randomint(5) between 0 , 5). problem having figuring out how create number of rows based off number inputted. have don't believe works. example of out come should if these numbers inputted.

generaterandompositions(4, 5, 30) int[][] posb = new int[][] { { 3,21 },  { 4,15 }, { 1,17 } { 3,9 } }; 

there 4 rows because 4 inputted number. other numbers randomly generated. need figuring out how create number of rows based off numbers variable inputted. new programming , suggestions , appreciated.

public static int[][] generaterandompositions(int number, int width, int height){     int[][] pos = new int[number][2];     for(int j=0; j <number; j++){        pos[j][0] = utility.randomint(width);        pos[j][1] = utility.randomint(height);     }     return pos; } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -