title: Reverse a string in Java, in O(1)?
body: <p>Is there any facility in the standard Java libraries that, given a CharSequence, produces the reverse in O(1) time? </p>
  
  <p>I guess this is "easy" to implement, just wondering whether it already exists. (I suspect the reason this is not offered is because the "easy" way would actually break multi-char code-points - but in many cases we know we are not dealing with those).</p>
  
  <p>Thanks</p>
  
  <p><strong>Update</strong> 
  Heh, it's a bit amusing that most thought this "impossible", good work guys! Well, actually it is (conceptually) trivial - pseudojava follows to make it clear: </p>
  
  <pre><code>class MyReverseString extends String { //of course I can't extend String!
     final String delegate;
     MyReverseString(String delegate) { this.delegate = delegate; }
  
     int length() { return delegate.length(); }
  
     int charAt(int i) { return delegate.charAt(delegate.length() - 1 - i); }
  }
  </code></pre>
  
  <p>I'm leaving the question open for some more, just in the rare event that something like the obvious solution (e.g. see Jon Skeet's one) already exists in the JDK and someone knows about it. (Again, highly unlikely due to those nasty code points).</p>
  
  <p><strong>Edit</strong> Probably the confusion came from me having "string" in the title (but not String!), whereas I only ask for "the reverse of a CharSequence". If you were confused, sorry. I would have hoped the O(1) part would make exactly clear what was being asked for.</p>
  
  <p>And by the way, <a href="https://stackoverflow.com/questions/3083154/how-can-i-get-the-last-integer-56-from-string-like-ra12ke43sh56/3110200#3110200">this was the question that made me ask this one</a>. (That's a case where it would be easier to run a regex from right-to-left, not left-to-right, so there may be some practical value even for the simple/broken-codepoints implementation)</p>