title: What is the time complexity of String.toCharArray(), O(n) or O(1)
body: <p>Suppose you want to convert a String of length n to a character array of length n.</p>
  
  <pre><code>char [] chArray = someString.toCharArray();
  </code></pre>
  
  <p>What is the computation complexity?O(n) or O(1) ( n: length of someString)</p>
  
  <p>I am under the impression that all it does is to allocate memory of size n*sizeof(char) and make a copy of that string to that location. So copying n cells of memory takes  O(n) time. Is it ? </p>
  
  <p>or it could be O(1), ( simple pointer relocation or as mentioned <a href="https://stackoverflow.com/questions/9476692/time-complexity-of-array-manipulation">here</a>)?</p>