将阵列与2维组合在一起

时间:2014-08-20 20:39:02

标签: java

我需要一点对齐我的数组。我需要更多的矢量,然后做一个添加行。我的第一列是复选框。

第0行应该是L,它有array1
第1行应该R具有array2
Row3应该是具有array3的S

        String array1[] = { dateString1, "10:18:17 PM"};
        String array2[] = {"08:09:110 AM", "10:00:33 AM"};
        String array3[] = {"09:00:561 PM", "07:12:19 AM"};
        String array4[] = { dateString1, "10:18:17 PM"};
        String array5[] = {"08:09:101 AM", "10:00:33 AM"};
        String array6[] = {"09:00:561 PM", "07:12:19 AM"};
        String array7[] = { dateString1, "10:18:17 PM"};
        String array8[] = {"08:09:1011 AM", "10:00:33 AM"};


        String[] p = {"L", "S", "R", "T", "D", "C", "L", "R"};

        boolean[] t3;

欲望输出:

L   dateString1 10:18:17 PM
S   08:09:110 AM    10:00:33 AM
R   09:00:561 PM    7:12:19 AM

等......

1 个答案:

答案 0 :(得分:-1)

我建议如下:

public String[] returnArray(int num){
switch(num)
  case 1 : return array1;
  case 2 : return array2;
  .
  .
  .
  case 8 : return array8;
  default : return null //this shouldn't really happen but its required to return something.
}

public void printArray(){
   for(int i=0;i<p.length;i++){
      System.out.print(p[i] + " " );
      for(String s : returnArray(i+1)) System.out.print(s + " ");
      System.out.println();
   }
}