Transform CharSequence.length to property

This commit is contained in:
Denis Zharkov
2015-10-11 17:32:31 +03:00
committed by Mikhail Glukhikh
parent 6c0d55e4ed
commit 1305d9755a
14 changed files with 83 additions and 50 deletions
@@ -3,6 +3,7 @@ import java.util.*;
public class J {
public static class B extends A {
public int getLength() { return 456; }
public char get(int index) {
if (index == 1) return 'a';
return super.get(index);
@@ -13,6 +14,10 @@ public class J {
B b = new B();
CharSequence cs = (CharSequence) b;
if (cs.length() != 456) return "fail 01";
if (b.length() != 456) return "fail 02";
if (b.getLength() != 456) return "fail 03";
if (cs.charAt(0) != 'z') return "fail 1";
if (b.get(0) != 'z') return "fail 2";