title: Getting length of array in java
body: <p>Please advice why if i try to get length of an array, my little application always getting error.</p>
  
  <p>Please find my code below:</p>
  
  <p><strong>1. String Parser</strong></p>
  
  <pre><code>    package dl.data.background;
  
      import java.util.ArrayList;
          public class StringParser {
  
          public StringParser()
          {
  
          }
  
          public ArrayList&lt;Object&gt; Parse (String input) {
              ArrayList&lt;Object&gt; output = new ArrayList &lt;Object&gt;();
  
              int pointer = 0;
              String data = "";
  
              while (pointer &lt;= input.length()-1)
              {
                  if(input.charAt(pointer) == '#'){
                      output.add(data);
                      data = "";
                      pointer++;
                  }
                  if(pointer &lt; input.length())
                  {
                      data += input.charAt(pointer);
                  }
                  pointer++;
              }
              return output;
          }
      } 
  </code></pre>
  
  <p><strong>2. Downloading data</strong></p>
  
  <pre><code>    package dl.data.background;
  
      import java.io.BufferedReader;
      import java.io.InputStream;
      import java.io.InputStreamReader;
      import java.util.ArrayList;
  
      import org.apache.http.HttpResponse;
      import org.apache.http.client.methods.HttpGet;
      import org.apache.http.impl.client.DefaultHttpClient;
  
      import android.app.Activity;
      import android.os.AsyncTask;
      import android.os.Bundle;
      import android.view.View;
      import android.widget.TextView;
  
      public class BackgroundDataActivity extends Activity {
      private TextView textView;
  
  
  
      /** Called when the activity is first created. */
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      textView = (TextView) findViewById(R.id.TextView01);
  
      }
  
      private class DownloadWebPageTask extends AsyncTask&lt;String, Void, String&gt; {
      @Override
      protected String doInBackground(String... urls) {
        String response = "";
        for (String url : urls) {
          DefaultHttpClient client = new DefaultHttpClient();
          HttpGet httpGet = new HttpGet(url);
          try {
            HttpResponse execute = client.execute(httpGet);
            InputStream content = execute.getEntity().getContent();
  
            BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
            String s = "";
            while ((s = buffer.readLine()) != null) {
              response += s;
            }
  
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
        return response;
      }
  
      protected void onPostExecute(String result) {
          StringParser stringParser = new StringParser();
              ArrayList&lt;Object&gt; arrayList = stringParser.Parse(result);
  
              Object [] output = arrayList.toArray();
  
              // how to get length of output array?? 
          textView.setText(output.length);
  
        }
      }
  
      public void readWebpage(View view) {
        DownloadWebPageTask task = new DownloadWebPageTask();
        String url1 = "http://atmbersama.16mb.com/atmlocator.php?ct=SEL_Id&amp;lat=-6.302161&amp;lng=106.743679&amp;radius=20";
  
        task.execute(new String[] {url1});
         }
       }
  </code></pre>
  
  <p>how to get length of output array??   </p>
  
  <pre><code>textView.setText(output.length);
  </code></pre>