JAVA API学习笔记二 java.lang.*

Interface CharSequence

包含四个方法

char charAt(int index)
返回指定位置字符值,可能引发越界异常.
int length()
返回字符串长度
CharSequence subSequence(int start, int end)
返回start开始到end结束的字符序列
String toString()
返回字符串.

示例:
package com.zww.test;


public class CharSequenceTest {


public static void main(String args[]){
CharSequence csq="I am a boy";

System.out.println(csq.charAt(0));

System.out.println(csq);

System.out.println(csq.toString());

System.out.println(csq.length());

System.out.println(csq.subSequence(0, 3));
}

}


运行结果:

I
I am a boy
I am a boy
10
I a

你可能感兴趣的:(JAVA API学习笔记二 java.lang.*)