Saving the value of an array in a method

I will just post the pseuducode, hope you will understand: >>import java.util*.; >main method { >> subemethod1(); submethod1() { Screen input = new Scanner(System.in); int buy = input.nextInt(); if( buy != 0) { submethod2(); } submethod2() { Screen input = new Scanner(System.in); int[][]grid = new int [5][6] int row = input.nextInt(); int col = input.nextint(); grid[row][col] = 1; Let's assume I typed 1 for row, and 1 for col this time. then `grid[1][1] = 1`. I want to save the value of `grid[1][1]` so that next time I enter row 2, col 2 I will have: grid[1][1] = 1; grid[2][2] = 1; and so on for whatever row-col combination I type. lastly I want to return to submethod1, and I want submethod1 to understand that grid[1][1] = 1 and that grid[2][2] also has the value 1; and so on....

以上就是Saving the value of an array in a method的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏