JDK之String源码解读(三)

版权声明:本文为博主原创文章,欢迎转载,转载请标明出处。 https://blog.csdn.net/qq_32523587/article/details/86555452

目录

 

codePointAt(int index)

codePointBefore(int index)

codePointCount(int beginIndex, int endIndex)

getChars(char dst[], int dstBegin)

getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)

getBytes(String charsetName)

getBytes(Charset charset)

getBytes()

equals(Object anObject)


codePointAt(int index)

作用:获取String中指定位置的代码点。

codePointBefore(int index)

作用:获取String中指定位置前一位的代码点。

其中,codePointBeforeImpl(char[] a, int index, int start)方法如下:

codePointCount(int beginIndex, int endIndex)

作用:获取String指定范围内的代码点个数。

getChars(char dst[], int dstBegin)

作用:将String的所有内容复制到char dst[]的指定位置后面。该方法不作范围检查。

getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)

作用:将String的内容复制到char dst[]里去。

getBytes(String charsetName)

作用:使用指定的字符集,获取String对应的字符数组。

getBytes(Charset charset)

作用:与上一个方法作用相同,不同之处在于,字符集的格式是Charset类型的。

getBytes()

作用:使用默认的字符集,获取String对应的字符数组。

equals(Object anObject)

作用:比较当前String和指定的Object anObject是否相等。

猜你喜欢

转载自blog.csdn.net/qq_32523587/article/details/86555452