Package Summary  Overview Summary

class:CharSequence [CHANGED]

  • All Known Implementing Classes:
    CharBuffer, String, StringBuffer, StringBuilder


    public interface CharSequence
    
    A CharSequence is a readable sequence of char values. This interface provides uniform, read-only access to many different kinds of char sequences. A char value represents a character in the Basic Multilingual Plane (BMP) or a surrogate. Refer to Unicode Character Representation for details.

    This interface does not refine the general contracts of the equals and hashCode methods. The result of comparingtesting two objects that implement CharSequence for equality is therefore, in general, undefined. Each object may be implemented by a different class, and there is no guarantee that each class will be capable of testing its instances for equality with those of the other. It is therefore inappropriate to use arbitrary CharSequence instances as elements in a set or as keys in a map.

    Since:
    1.4
  • All Known Implementing Classes:
    CharBuffer, String, StringBuffer, StringBuilder


    public interface CharSequence
    
    A CharSequence is a readable sequence of char values. This interface provides uniform, read-only access to many different kinds of char sequences. A char value represents a character in the Basic Multilingual Plane (BMP) or a surrogate. Refer to Unicode Character Representation for details.

    This interface does not refine the general contracts of the equals and hashCode methods. The result of comparing two objects that implement CharSequence is therefore, in general, undefined. Each object may be implemented by a different class, and there is no guarantee that each class will be capable of testing its instances for equality with those of the other. It is therefore inappropriate to use arbitrary CharSequence instances as elements in a set or as keys in a map.

    Since:
    1.4
  • All Known Implementing Classes:
    CharBuffer, String, StringBuffer, StringBuilder


    public interface CharSequence
    
    A CharSequence is a readable sequence of char values. This interface provides uniform, read-only access to many different kinds of char sequences. A char value represents a character in the Basic Multilingual Plane (BMP) or a surrogate. Refer to Unicode Character Representation for details.

    This interface does not refine the general contracts of the equals and hashCode methods. The result of testing two objects that implement CharSequence for equality is therefore, in general, undefined. Each object may be implemented by a different class, and there is no guarantee that each class will be capable of testing its instances for equality with those of the other. It is therefore inappropriate to use arbitrary CharSequence instances as elements in a set or as keys in a map.

    Since:
    1.4

method:compare(java.lang.CharSequence, java.lang.CharSequence) [ADDED]

  • compare

    static int compare​(CharSequence cs1,
                       CharSequence cs2)
    
    Compares two CharSequence instances lexicographically. Returns a negative value, zero, or a positive value if the first sequence is lexicographically less than, equal to, or greater than the second, respectively.

    The lexicographical ordering of CharSequence is defined as follows. Consider a CharSequencecs of length len to be a sequence of char values, cs[0] to cs[len-1]. Suppose k is the lowest index at which the corresponding char values from each sequence differ. The lexicographic ordering of the sequences is determined by a numeric comparison of the char values cs1[k] with cs2[k]. If there is no such index k, the shorter sequence is considered lexicographically less than the other. If the sequences have the same length, the sequences are considered lexicographically equal.

    Parameters:
    cs1 - the first CharSequence
    cs2 - the second CharSequence
    Returns:
    the value 0 if the two CharSequence are equal; a negative integer if the first CharSequence is lexicographically less than the second; and a positive integer if the first CharSequence is lexicographically greater than the second.
    Since:
    11