title: Android - Working with Multidimensional String Arrays
body: <p>I'm having trouble working with multidimensional strings arrays and would appreciate any clarity.</p>
  
  <p>I'll post a sample code below that I wrote just to play around with to get an idea of how multidimensional string arrays work. I wrote in comments what I expect to be happening and what I expect the result to be, but isn't. My questions is pretty much why isn't it working the way I am thinking, it should create the matrix
  [1][2][3]</p>
  
  <p>[4][5][6]</p>
  
  <p>Also an additional question, if I have the 2x3 martrix already setup, how can I reassign the value in a specific element, for example [1][1], or do I have to call the row and assign it to a variable. This whole sample code is for me to learn how to assign elements in a multidimensional string array and then reassign them. These string array lists, I do not know the dimension ahead of time and the values change, there I need to use the .add method and eventually .set.</p>
  
  <p>Thank you in advance for any help, amazing community it seems to be at Stack Overflow</p>
  
  <pre><code>TextView displayanswer;
  String text0, text1, text2, text3, text4, text5, text6;
  ArrayList&lt;String&gt; column = new ArrayList&lt;String&gt;();
  ArrayList&lt;ArrayList&lt;String&gt;&gt; row = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.test1);
      displayanswer = (TextView) findViewById(R.id.textView1);
  
      //Creates Matrix in column variable of [1][2][3]
      column.add("1");
      column.add("2");
      column.add("3");  
  
      row.add(column);  //Creates Matrix in row variable of [1][2][3]
      row.add(column);  //Creates 2 dimension matrix of  [1][2][3]
                       //                                [1][2][3]
  
      column.set(0, "4"); //column variable Matrix becomes  [4][2][3]
      column.set(1, "5"); //column variable Matrix becomes  [4][5][3]
      column.set(2, "6"); //column variable Matrix becomes  [4][5][6]
      row.set(1,column);  //2 dimensional matrix becomes  [1][2][3]
                                                                    //[4][5][6]
  
             column = row.get(0); //get first row of 2 row matrix, should be[1][2][3]
  
      //Assigning first row elements to text strings
      text0 = column.get(0); text1 = column.get(1); text2 = column.get(2);
  
      column = row.get(1); //gets second row of 2 row matrix, should be [4][5][6]
  
      //Assigning second row elements to text strings
      text3 = column.get(0); text4 = column.get(1); text5 = column.get(2);
  
      //should give me 123456 but instead I get 456456???
      displayanswer.setText(""+text0 +text1 +text2 +text3 +text4 +text5);
  
  }
  </code></pre>
  
  <p>}</p>