title: Best way to get part of content from string in java
body: <p>I have a string like below</p>
  
  <pre><code>12SELVASOFTWAREENGINEER................323
  </code></pre>
  
  <p>This string length is more than <code>10000</code></p>
  
  <p>First two letter of this string is employee Id</p>
  
  <p>So i can get my employee id like below</p>
  
  <pre><code>String empid = str.substring(0,2);
  </code></pre>
  
  <p>but this string creates the same space for original <code>String</code>, so memory leak will happen.</p>
  
  <p>How to avoid this?</p>
  
  <p>Is their any alternative or efficient way is their for getting the part of the string in java</p>
  
  <p>Any help will be greatly appreciated!!!</p>