title: How to store a space in a char array?
body: <p>I'm writing a Caesar Cypher program but I can't figure out how to store a space in my char array. Here is my encrypt method</p>
  
  <pre><code>public static String encrypt(String msg, int shift)  {
      char[] list = msg.toCharArray();
      for (int i = 0; i &lt; list.length; i++) {
          // Shift letter
          char letter = list[i];
          letter = (char) (letter + shift);
          if (letter &gt; 'z') {
              letter = (char) (letter - 26);
          }
          else if (letter &lt; 'a') {
              letter = (char) (letter + 26);
          }
          else if (letter == ' ') {
              letter = '\0';
          }
          list[i] = letter;
      }
      // Return final string.
      return new String(list);
  }
  </code></pre>