android - Using .split and getting content -


i have group of numbers divided comma(4 numbers in it) , groups divided ":".

example(you see 3 groups): 2,0,6,46:3,14,22,12:0,45,65,12: .....

i want take numbers; mean : num[3][2] -> choose group which's first value 3 , 2 means take 2.value of group -> in example give 14

i want exist values: num[0][0,1,2,3,4]; num[1][0,1,2,3,4]....

  • how can take group count?
  • what kind of loop statement can use every value?

i think cant go code further:

int[][] num = new int[count of groups ][4]; // 4 number count in group string[] separated = stringtime.split(".|\\:"); num[0][0]= integer.parseint(separated[0]); num[0][1]= integer.parseint(separated[1]); num[0][2]= integer.parseint(separated[2]); num[0][3]= integer.parseint(separated[3]); 

string[] parts = string.split(":"); // split ':' groups int[][] num = new int[parts.length() ][4]; // make integer 2d array did  (int i=0; < parts.length(); i++){ // run loop each outer/larger group     string[] subparts = parts[i].split(","); // each integer in subgroup splitting using ',' delimiter      num[i][0]= integer.parseint(subparts[0]); // getting integers 2d array, same as:     num[i][1]= integer.parseint(subparts[1]);     num[i][2]= integer.parseint(subparts[2]);     num[i][3]= integer.parseint(subparts[3]); } 

hope helps. haven't run code should work.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -