字符串API简介

1、char charAt(int index);

  返回给定位置的代码单元。除非对底层的代码单元感兴趣,否则不需要调用这个方法。

2、int codePointAt(int index)  5.0

    返回从给定位置开始或结束的代码点

3、int offsetByCodePoints(int startIndex,int cpCount )

    返回从startIndex代码点开始,位移到cpCount后的代码点索引

4、int compare(String other)

    按照字典顺序,如果字符串位于other之前,返回一个负数如果字符串位于other之后,返回一个正数;如果两个字符串相等,返回0.

5、boolean endWith(String suffix)

    如果字符串以suffix结尾,返回true;

6、boolean equals(Object other)

    如果字符串与other相等,返回true;

7、boolean equalsIgnoreCase(String other)

    如果字符串与other相等(忽略大小写),返回true;

8、int indexOf(String str)

     int indexOf(String str, int fromIndex)

     int indexOf(int cp)

     int indexOf(int cp, int fromIndex)

返回与字符串str或代码点cp匹配的第一个子串的开始位置,这个位置从索引0或fromIndex开始计算,如果在原始串中不存在str,返回-1;

9、

     int lastindexOf(String str)

     int lastindexOf(String str, int fromIndex)

     int lastindexOf(int cp)

     int lastindexOf(int cp, int fromIndex)

返回与字符串str或代码点cp匹配的最后一个子串的开始位置。这个位置从原始串尾端或fromIndex开始计算

10、int length()

    返回字符串的长度

11、 int codePointCount(int startIndex, int endIndex)

    返回startIndex和endIndex-1之间的代码点数量,没有配成对的代用字符将计入代码点

12、String replace(CharSequence oldString,CharSequence newString);

    返回一个新的字符串,这个字符串用newString代替原始字符串中所有的oldString。可以用String或StringBuilder对象作为      CharSequence参数;

13、Boolean startWith(String prefix)

    如果字符串以以prefix字符串开始返回true

14、String substring(int beginIndex)

       String substring(int beginIndex,int endIndex)

       返回一个新的字符串,这个字符串包含原始的字符串中从beginIndex到串尾或endIndex-1的所有代码单元

15、String toLowerCase()

    返回一个新的字符串,这个字符串将原始字符串中所有的大写字母改成小写字母。

16、String toUpperCase()

    返回一个新的字符串,这个字符串将原始字符串中所有的小字母改成大写字母。

17、String trim()

    返回一个新的字符串,这个字符串将删除除了原始字符串头部和尾部的空格

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值