Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

StringBuffer.reverse();

Name: Anonymous 2008-01-14 5:10

public class MainClass {
  public static void main(String args[]) {
    StringBuffer sb1 = new StringBuffer("abcde");
    sb1.append("abcdefghij");
    StringBuffer sb2 = sb1.reverse();
    System.out.println(sb1);
    System.out.println(sb2);
  }
}


Why the fuck is jihgfedcbaedcba also being assigned to sb1?

Name: Anonymous 2008-01-14 6:55

>>3
That's why you read the API. It reverses in place, and then returns a reference to this for no particular reason.
So not only do sb1 and sb2 have the same value in your example, they're the same object.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List