java String 形参值传递问题 StringBuffer StringBuilder引用传递 ----- jvm的功劳

java string 的 形参值传递方法

调试后 走的此 构造方法

发现当把 String 当形参传递时,调用的构造方法 如下:

 * Allocates a new {@code String} that contains characters from a subarray
 * of the character array argument. The {@code offset} argument is the
 * index of the first character of the subarray and the {@code count}
 * argument specifies the length of the subarray. The contents of the
 * subarray are copied; subsequent modification of the character array does
 * not affect the newly created string.
 *
public String(char value[], int offset, int count) {// }

且 将 offset count 等都正确赋值
怀疑是 jvm 进行的优化

一开始的猜测 是 此 构造方法 ---- error
public String(String original) {
this.value = original.value;
this.hash = original.hash;
}

StringBuffer 作为形参的时候,传递的是 对象自身 (引用)
跟踪过 没有 调用 任何 构造方法。

String ss = “www.” 究竟做了什么???

欢迎评论留言
可以看看

本文主要翻译自JDK 1.8的JVM监控工具jhat中关于OQL的英文帮助说明。

可以在jhat 和 jvisualvm 中进行实践。

OQL(对象查询语言)

源码阅读

jdk git hub
gitee

wait 创建的 对象监视器 什么时候释放?

notify/notifyAll 对象exit 销毁
这个 对象监视器 属于 那种锁?
这篇博主的文章值得一读
这一篇更全面

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值