JDK之String源码解读(二)

目录

checkBounds(byte[] bytes, int offset, int length)

String(byte bytes[], int offset, int length, String charsetName)

String(byte bytes[], int offset, int length, Charset charset)

String(byte bytes[], String charsetName)

String(byte bytes[], Charset charset)

String(byte bytes[], int offset, int length)

String(byte bytes[])

String(StringBuffer buffer)

String(StringBuilder builder)

String(char[] value, boolean share)

length()

isEmpty()

charAt(int index)


checkBounds(byte[] bytes, int offset, int length)

作用:一个公共专用工具。用于边界检查字节数组和字符串构造函数使用的请求偏移量和长度值是否合法。

String(byte bytes[], int offset, int length, String charsetName)

作用:使用特定的字符集,用byte bytes[]中特定的位置内容,初始化String。

String(byte bytes[], int offset, int length, Charset charset)

作用:该方法与上一个方法作用一样,不同之处在于它的字符集是Charset类型,而不是String类型。

String(byte bytes[], String charsetName)

作用:使用特定的字符集,用byte bytes[]中的所有内容,初始化String。

String(byte bytes[], Charset charset)

作用:使用特定的字符集,用byte bytes[]中的所有内容,初始化String。与上一个方法不同的是,它的字符集是Charset类型,而不是String类型。

String(byte bytes[], int offset, int length)

作用:用byte bytes[]中特定的位置内容,初始化String。使用的是默认字符集。

String(byte bytes[])

作用:用byte bytes[]中所有内容,初始化String。使用的是默认字符集。

String(StringBuffer buffer)

作用:用StringBuffer buffer,初始化String。

String(StringBuilder builder)

作用:跟上一个方法类似,不同的是,该方法没有使用synchronized上锁。

String(char[] value, boolean share)

作用:使用char[] value初始化String。

length()

作用:获取String的字符数组长度。

isEmpty()

作用:判断String是否为空。

charAt(int index)

作用:获取String指定位置处的char值。

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值