Saturday 15 March 2014

How to retain newly added values on a two-dimensional array (JAVA) -



How to retain newly added values on a two-dimensional array (JAVA) -

i'm stuck @ part of program. these 2 options pupil info scheme (not using gui/joption , without linking database. have 2-dimensional array (string records[][] = new string [5][3];) has first 2 "rows" ([0][0] [0][2] , [1][0] [1][2]) filled pre-assigned info (first name, lastly name, course). if below, part "b" or "b" alternative selected, adding new values new array (incremented when alternative b used, assign first [2][0], [3][0] , on). seemed work since show info i've entered added , displayed in proper order. problem is: when take 'y" homecoming top menu , select alternative view newly added record (using id number 2), shows contains "null". there i've missed? missing step need in order finish program. ahead help.

if("a".equals(option1)|| "a".equals(option1)){ system.out.println("please come in pupil id record view."); string = reader1.readline(); idcheck = integer.parseint(a); x1=idcheck; for(int y=0;y<3;y++){ system.out.print(records[x1][y] + " "); } system.out.println("\nreturn main menu or exit? (y/n)"); cont1= reader1.readline(); } else if("b".equals(option1)||"b".equals(option1)){ arr_count++; (int y = 0; y<3;y++){ system.out.println("enter value "+ alternative [y]+":" ); string x = reader1.readline(); records[arr_count][y] = x; }

java arrays multidimensional-array

No comments:

Post a Comment