String類學習總結

来源:互联网 发布:程序员转行一般做什么 编辑:程序博客网 时间:2024/06/02 05:31

|--String
    |--获取
        |--返回指定所引处的字符
            |--char charAt(int index);
        |--返回指定所引处字符对应的Unicode码
            |--int codePointAt(int index);
        |--将指定字符串连接到此字符串的结尾
            |--String concat(String str);
        |--返回此字符串的哈希码
            |--int hashCode();
        |--返回指定字符在字符串中第一次出现的索引
            |--int indexOf(int ch);
        |--返回指定字符在字符串中最后一次出现的索引
            |--int lastindexOf(int ch);
        |--返回指定字符在字符串中第一次出现的索引,从指定的索引处开始搜索
            |--int indexOf(int ch, int fromIndex);
        |--返回指定字符在字符串中最后一次出现的索引,从指定的索引处反向搜索
            |--int lastIndexOf(int ch, int fromIndex);
        |--返回指定子字符串在此字符串中第一次出现的索引
            |--int indexOf(String str);
        |--返回指定子字符串在此字符串中最后一次出现的索引
            |--int lastIndexOf(String str);
        |--返回指定子字符串在此字符串中第一次出现的索引,从指定的索引处开始搜索
            |--int indexOf(String str, int fromIndex);
        |--返回指定子字符串在此字符串中最后一次出现的索引,从指定的所引出反向搜索
            |--int lastIndexOf(String str, int fromIndex);
        |--返回此字符串的长度
            |--int length();
        |--返回一个新的字符串
            |--String replace(char oldChar, char newChar);
            |--String replace(CharSequence target,CharSequence replacement);
        |--根据给定正则表达式的匹配拆分字符串
            |--String[] split(String regex);
            |--String[] split(String regex,int limit);
        |--返回一个新的字符序列,它是此序列的一个子序列
            |--Char Seuqence subSequence(int beginIndex, int endIndex);
        |--返回一个新的字符串,它是此字符串的一个子字符串
            |--String substring(int beginIndex);
            |--String substring(int beginIndex, int endIndex);
        |--返回字符串对象
            |--String toString();
        |--返回字符串的副本,忽略前导空格和后不空格
            |--String trim();
    |--判断
        |--按字典顺序比较两个字符串
            |--int compareTo(String anotherString);
        |--当且仅当字符串包含指定字符值序列时,返回true
            |--String contains(CharSequence s);
        |--测试此字符串是否以指定的后缀结束
            |--boolean endsWith(String suffix);
        |--测试此字符串是否以指定的前缀开始
            |--boolean startsWith(String prefix);
        |--测试此字符串从索引处的子字符串是否以指定前缀开始
            |--boolean startsWith(String prefix, int toffset);
        |--将此字符串与指定对象比较
            |--boolean equals(Object anObject);
        |--将此字符串与另一个字符串比较,忽略大小写
            |--boolean equalsIgnoreCase(String anotherString);
        |--当且仅当length()为0时返回true
            |--boolean isEmpty();
    |--转换
        |--将字符串中所有字符转换为小写
            |--String toLowerCase();
            |--String toLowerCase(Locale locale);
        |--将字符串中所有字符转换为大写
            |--String toUpperCase();
            |--String toUpperCase(Locale locale);
        |--返回指定数组中标识该字符序列的字符串
            |--String(char[] value)
            |--String(char[] value, int offset, int count)
            |--static String copyValueOf(char[] data);
            |--static String copyValueOf(char[] data, int offset, int count);
        |--将此字符串转换为一个新的字符数组
            |--char[] toCharArray();
        |--将此字节数组转换为一个字符串
            |--String(byte[] bytes)
            |--String(byte[] bytes,int offset, int length)
        |--使用指定的字符集将此字符串编码到byte序列,将结果存储到一个byte数组中
            |--byte[] getBytes();
            |--byte[] getBytes(Charset charset);
            |--byte[] getBytes(String charsetName);
        |--返回boolean参数的字符串表现形式
            |--static String valueOf(boolean b);
        |--返回char参数的字符串表现形式
            |--static String vlaueOf(char c);
        |--返回char数组参数的字符串表现形式
            |--static String valueOf(char[] data);
        |--返回char数组参数的特定子数组的字符串表现形式
            |--static String valueOf(char[] data, int offset, int count);
        |--返回double参数的字符串表现形式
            |--static String valueOf(double d);
        |--返回float参数的字符串表现形式
            |--static String valueOf(flaot f);
        |--返回int参数的字符串表现形式
            |--static String valueOf(int i);
        |--返回long参数的字符串表现形式
            |--static String valueOf(long l);
        |--返回Object参数的字符串表现形式
            |--static String valueOf(Object obj);