Source Home >> Java Source 1.6.0 >> java.lang.CharSequence V 0.09
  • 01/*
  • 02 * @(#)CharSequence.java 1.9 05/11/17
  • 03 *
  • 04 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
  • 05 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  • 06 */
  • 07
  • 08package java.lang;
  • 09
  • 10
  • 11/**
  • 12 * A <tt>CharSequence</tt> is a readable sequence of <code>char</code> values. This
  • 13 * interface provides uniform, read-only access to many different kinds of
  • 14 * <code>char</code> sequences.
  • 15 * A <code>char</code> value represents a character in the <i>Basic
  • 16 * Multilingual Plane (BMP)</i> or a surrogate. Refer to <a
  • 17 * href="Character.html#unicode">Unicode Character Representation</a> for details.
  • 18 *
  • 19 * <p> This interface does not refine the general contracts of the {@link
  • 20 * java.lang.Object#equals(java.lang.Object) equals} and {@link
  • 21 * java.lang.Object#hashCode() hashCode} methods. The result of comparing two
  • 22 * objects that implement <tt>CharSequence</tt> is therefore, in general,
  • 23 * undefined. Each object may be implemented by a different class, and there
  • 24 * is no guarantee that each class will be capable of testing its instances
  • 25 * for equality with those of the other. It is therefore inappropriate to use
  • 26 * arbitrary <tt>CharSequence</tt> instances as elements in a set or as keys in
  • 27 * a map. </p>
  • 28 *
  • 29 * @author Mike McCloskey
  • 30 * @version 1.9 05/11/17
  • 31 * @since 1.4
  • 32 * @spec JSR-51
  • 33 */
  • 34
  • 35public interface CharSequence {
  • 36
  • 37 /**
  • 38 * Returns the length of this character sequence. The length is the number
  • 39 * of 16-bit <code>char</code>s in the sequence.</p>
  • 40 *
  • 41 * @return the number of <code>char</code>s in this sequence
  • 42 */
  • 43 int length();
  • 44
  • 45 /**
  • 46 * Returns the <code>char</code> value at the specified index. An index ranges from zero
  • 47 * to <tt>length() - 1</tt>. The first <code>char</code> value of the sequence is at
  • 48 * index zero, the next at index one, and so on, as for array
  • 49 * indexing. </p>
  • 50 *
  • 51 * <p>If the <code>char</code> value specified by the index is a
  • 52 * <a href="Character.html#unicode">surrogate</a>, the surrogate
  • 53 * value is returned.
  • 54 *
  • 55 * @param index the index of the <code>char</code> value to be returned
  • 56 *
  • 57 * @return the specified <code>char</code> value
  • 58 *
  • 59 * @throws IndexOutOfBoundsException
  • 60 * if the <tt>index</tt> argument is negative or not less than
  • 61 * <tt>length()</tt>
  • 62 */
  • 63 char charAt(int index);
  • 64
  • 65 /**
  • 66 * Returns a new <code>CharSequence</code> that is a subsequence of this sequence.
  • 67 * The subsequence starts with the <code>char</code> value at the specified index and
  • 68 * ends with the <code>char</code> value at index <tt>end - 1</tt>. The length
  • 69 * (in <code>char</code>s) of the
  • 70 * returned sequence is <tt>end - start</tt>, so if <tt>start == end</tt>
  • 71 * then an empty sequence is returned. </p>
  • 72 *
  • 73 * @param start the start index, inclusive
  • 74 * @param end the end index, exclusive
  • 75 *
  • 76 * @return the specified subsequence
  • 77 *
  • 78 * @throws IndexOutOfBoundsException
  • 79 * if <tt>start</tt> or <tt>end</tt> are negative,
  • 80 * if <tt>end</tt> is greater than <tt>length()</tt>,
  • 81 * or if <tt>start</tt> is greater than <tt>end</tt>
  • 82 */
  • 83 CharSequence subSequence(int start, int end);
  • 84
  • 85 /**
  • 86 * Returns a string containing the characters in this sequence in the same
  • 87 * order as this sequence. The length of the string will be the length of
  • 88 * this sequence. </p>
  • 89 *
  • 90 * @return a string consisting of exactly this sequence of characters
  • 91 */
  • 92 public String toString();
  • 93
  • 94}

文件:CharSequence.java
包名:java.lang
类名:CharSequence
继承:
接口: