title: Converting Char Array to List in Java
body: <p>Can anyone help me and tell how to convert a <code>char</code> array to a list and vice versa.
  I am trying to write a program in which users enters a string (e.g <code>"Mike is good"</code>) and in the output, each whitespace is replaced by <code>"%20"</code> (I.e <code>"Mike%20is%20good"</code>). Although this can be done in many ways but since insertion and deletion take O(1) time in linked list I thought of trying it with a linked list. I am looking for someway of converting a <code>char</code> array to a list, updating the list and then converting it back.</p>
  
  <pre><code>public class apples
  {
     public static void main(String args[])
     {
        Scanner input = new Scanner(System.in);
        StringBuffer sb = new StringBuffer(input.nextLine());
  
        String  s = sb.toString();
        char[] c = s.toCharArray();
        //LinkedList&lt;char&gt; l = new LinkedList&lt;char&gt;(Arrays.asList(c));
        /* giving error "Syntax error on token " char",
           Dimensions expected after this token"*/
      }
  }
  </code></pre>
  
  <p>So in this program the user is entering the string, which I am storing in a <code>StringBuffer</code>, which I am first converting to a string and then to a <code>char</code> array, but I am not able to get a list <code>l</code> from <code>s</code>.</p>
  
  <p>I would be very grateful if someone can please tell the correct way to convert <code>char</code> array to a list and also vice versa.</p>