Java - How to put special characters into a String
<p>Java seems to have very good string handling.  Still, I'm having problems with the simplest of problems.  I need to have dynamic strings (they change at run time) so a String type is not a good choice since they are immutable.  So I am using char arrays.  Kind of a pain to setup but at least they are modifiable.  I want to create a string constant with a carriage return/line feed pair in it (or other control characters).  In C/C++ you would just do this:</p>

<pre><code>char myString[100];
myString = "This is a string with a CR/LF pair\x0D\x0A";
</code></pre>

<p>And yes, I know in java you could use a "\r".  And yes, I know that you could use:</p>

<pre><code>myString[34] = 0x000D;
myString[35] = 0x000A;
</code></pre>

<p>And in Java you really cannot use a string literal constant to initialize a char array (can you??).  So how do you initialize a char array is the question?</p>
