StringView implements CharSequence { @Override public int length() { return end - start; } 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 testLength() { String orig = "abcde"; StringView view = new StringView(orig, -2, 17); assertEquals(5, view.length()); assertEquals('a', view.charAt(0)); assertEquals('e', view.charAt(4)); view = new StringView(orig, 1, 4); assertEquals(3, view.length()); assertEquals('b', view.charAt(0)); assertEquals('d', view.charAt(2)); }