2D Array applied operator & efficient menu set up - Java


2D Array 

Users can receive and choose a number from a menu bar by using the array in java, especially in this post since we are going to deal with two-dimensional arrays to prevent a redundant usage of choice and help make an efficient choice of selection from the user. 

 
                                        

if we put a menu below then we can make the list of the menu like a red box.

10- {"EXIT", "프로그램을 종료합니다."}
11- {"Main", "연산하기", "끝내기"},
12- {"연산", "새로운 연산", "이어서 연산", "이전 화면"}

To use of 2d array (two-dimensional array) we need to understand the basic concept of an Array.

1st length of the array is determined by the number of indexes

2nd index is the asset of the array. 

so the total number of indexes is the same as the length of the array. 

Here is the formula to explain above the logic with the java formula
String [ ] [ ]      menu       = {  { "EXIT", "프로그램을 종료합니다.~" }, 
random name { "MAIN", "연산하기", "끝내기" },
{ "연산", "새로운 연산", "이어서 연산", "이전 화면" } };


String [0] [A] = Asset 1
String [1] [B] = Asset 2  
String [2] [B] = Asset 3

Column  first, row later 
 

 table

A

B

C

0

Asset1

Asset7

Asset13

1

Asset2

Asset8

Asset14

2

Asset3

Asset9

Asset15

3

Asset4

Asset10

Asset16

4

Asset5

Asset11

Asset17

5

Asset6

Asset12

Asset18

                                                                  

 

  

Because we only make up a table (above the red box) with indexes, we need to fill up the first cell among ([][]) with the number 1! 

this.display(title);
this.display(this.makeSubMenu(menu[1]));






 



Comments