关于String方法中value,大牛解释解释这是属性还是方法,是哪个类的?

yusen0529 2016-07-06 01:52:02


public final class String
implements java.io.Serializable, Comparable<String>, CharSequence {
/** The value is used for character storage. */
private final char value[];

/** Cache the hash code for the string */
private int hash; // Default to 0

/** use serialVersionUID from JDK 1.0.2 for interoperability */
private static final long serialVersionUID = -6849794470754667710L;

/**
* Class String is special cased within the Serialization Stream Protocol.
*
* A String instance is written into an ObjectOutputStream according to
* <a href="{@docRoot}/../platform/serialization/spec/output.html">
* Object Serialization Specification, Section 6.2, "Stream Elements"</a>
*/
private static final ObjectStreamField[] serialPersistentFields =
new ObjectStreamField[0];

/**
* Initializes a newly created {@code String} object so that it represents
* an empty character sequence. Note that use of this constructor is
* unnecessary since Strings are immutable.
*/
public String() {
this.value = "".value ;
}

this.value = "".value ; 中value是啥?
...全文
717 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
sky_08_06_02 2016-08-18
  • 打赏
  • 举报
回复
引用 11 楼 yusen0529 的回复:
明白了,String 的成员变量 private value ,“”也是string类型,内部可以引用
yusen0529 2016-07-18
  • 打赏
  • 举报
回复
明白了,String 的成员变量 private value ,“”也是string类型,内部可以引用
dzq584462393 2016-07-07
  • 打赏
  • 举报
回复
源码中String不是private final char value[];有定义吗,String s = new String();把s中的属性value[]赋值为空串的value
Be_nurturing 2016-07-07
  • 打赏
  • 举报
回复
value是char类型的属性
qq_35537933 2016-07-07
  • 打赏
  • 举报
回复
太高深了,搞不懂
小灰狼 2016-07-07
  • 打赏
  • 举报
回复
都是 String 的成员变量
yusen0529 2016-07-06
  • 打赏
  • 举报
回复
这个是属性么?没有看到有定义呀?而且new出来的String 是没有这个属性的
scmod 2016-07-06
  • 打赏
  • 举报
回复

public String() {
        this.value = new char[0];
    }
没发现楼主那样的...
爱睡觉的阿狸 2016-07-06
  • 打赏
  • 举报
回复
当然是属性啦
qq_15915835 2016-07-06
  • 打赏
  • 举报
回复
难道没看注释吗
小白白啊啊 2016-07-06
  • 打赏
  • 举报
回复
属性
soton_dolphin 2016-07-06
  • 打赏
  • 举报
回复
是属性,方法后面要跟括号的

62,628

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧