title: reversing a String in java
body: <p>Code to revers a string in java:
  NOTE: One or two additional variables are fine. An extra copy of the array is not.</p>
  
  <p>Now  i have implemented a algo as follows:</p>
  
  <pre><code>public static void removeDuplicates(char[] str) {
    if (str == null) return;
    int len = str.length;
    if (len &lt; 2) return;
  
    int tail = 1;
  
    for (int i = 1; i &lt; len; ++i) {
     int j;
       for (j = 0; j &lt; tail; ++j) {
         if (str[i] == str[j]) break;
       }
       if (j == tail) {
         str[tail] = str[i];
         ++tail;
       }
     }
     str[tail] = something //something to mark end of char array eg '\0' as we have in C
   }
  </code></pre>