java - Making 2D array not have a fixed number of indexes -


i have 2d array [[1, 0, 0], [2, 0, 0], [3, 4, 5,], [6, 7, 0], null, [0, 0, 0]].

i want turn dynamic array, meaning want [[1], [2], [3, 4, 5], [6, 7], null, []].

below code trying out. can't seem it. suggestions?

public static int[][] getnonfixedarray(string string) {      string[] split = string.split("\\|", -1);     int[][] result = new int[split.length][3];      (int = 0; < split.length; i++) {         int[] array = getnonfixedarray(split[i]);          if (array != null) {              (int j = 0; j < array.length; j++) {                 result[i][j] = array[j];                  if (result[i][j] == 0) {                     result[i][j] = integer.parseint(" ");                 }             }         } else {             result[i] = null;         }     }      return result; } 

when go through inner arrays (the second loop), trying replace element value '0' integer.parseint(" ");. give exception anyway. might collect non-zero numbers (in list if can use list) , create array based on after second loop ends.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -