title: Passing a List object to a method in Android
body: <p>I am trying to use the following method:</p>
  
  <pre><code>public static String UrlToString(String targetURL, List params) {
          HttpClient client = new DefaultHttpClient();
          HttpPost post = new HttpPost(targetURL);
          List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
          params.add(new BasicNameValuePair("name", "xyz"));
          params.add(new BasicNameValuePair("home", "xyz"));
          post.setEntity(new UrlEncodedFormEntity(params));
          HttpResponse response = client.execute(post);
          InputStream input = response.getEntity().getContent();  
          //Get the string data from input string and return
          ...
  }
  </code></pre>
  
  <p>But i want the <code>List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();</code> to be passed with the values added from outside the method. If I remove the three lines from there, I get an error from Eclipse saying there is an uncaught exception. How do I pass the list to the method?</p>