StringView implements CharSequence { @Override public String toString() { return repr(); } StringView(String data);  StringView(String str, int start, int end); String data(); int start(); int end(); char lastChar(); StringView subview(int start0, int end0); String repr(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); @Override int length(); @Override char charAt(int index); @Override CharSequence subSequence(int start, int end);  }
@Test public void testBuilder() { String orig = "foobar"; StringView view = new StringView(orig, 1, 5); StringBuilder buf = new StringBuilder(); buf.append(view); assertEquals("ooba", buf.toString()); }