title: How to convert a comma separated String to ArrayList in Java
body: <p>I have a comma separated String which i need to convert to ArrayList .
  I tried this way </p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Arrays;
  
      public class Test {
  
          public static void main(String[] args) {
  
              String CommaSeparated = "item1 , item2 , item3";
  
              ArrayList&lt;String&gt; items = (ArrayList)Arrays.asList(CommaSeparated.split("\\s*,\\s*"));
  
              for(String str : items)
              {
                  System.out.println(str);
              }
  
          }
  
      }
  </code></pre>
  
  <p>Its giving me the Runtime Error as shown </p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
      at com.tradeking.at.process.streamer.Test.main(Test.java:14)
  </code></pre>
  
  <p>as i was trying to convert an List to arrayList by force .</p>