首页 / JAVA / Java源码----String
Java源码----String
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Java源码----String,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1424字,纯文字阅读大概需要3分钟。
内容图文
1.1 Java对连接操作(+)和其他对象转换成string提供了特殊的支持。连接操作通过StringBuilder或者StringBuffer的append()方法。
通过toString()方法实现转换操作。
1.2 在string构造器里面放一个null,会导致空指针异常。
1.3 构造器
1. public String() { this.value = "".value; }
2. public String(String original) { this.value = original.value; this.hash = original.hash; }
3. public String(char value[]) { this.value = Arrays.copyOf(value, value.length); } Arrays.copyOf()方法内部调用的是System.arraycopy
4. public String(char value[], int offset, int count)
5. public String(int[] codePoints, int offset, int count)
6. public String(byte ascii[], int hibyte, int offset, int count)
7. public String(byte ascii[], int hibyte)
8. public String(byte bytes[], int offset, int length, String charsetName) throws UnsupportedEncodingException
9. public String(byte bytes[], int offset, int length, Charset charset)
10. public String(byte bytes[], String charsetName) throws UnsupportedEncodingException
11. public String(byte bytes[], Charset charset)
12. public String(byte bytes[], int offset, int length)
13. public String(byte bytes[])
14. public String(StringBuffer buffer)
15. public String(StringBuilder builder)
16. ***String(char[] value, boolean share) 这个很重要,速度很快,但共享char数组。具体看实现。
1.4 内部方法
1. public int length()
2. public boolean isEmpty() { return value.length == 0; }
3. public char charAt(int index)
内容总结
以上是互联网集市为您收集整理的Java源码----String全部内容,希望文章能够帮你解决Java源码----String所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。