java中string什么意思

互联网 19-5-20

Java是面向对象的编程语言,它其中包含有各种各样的名词,都有着不同的意思。

Java中的string是字符串的意思,当声明了一个字符串变量时,便可以在里面存储数据。

String类

想要了解一个类,最好的办法就是看这个类的实现源代码,来看一下String类的源码:

public final class String     implements java.io.Serializable, Comparable<String>, CharSequence {     /** The value is used for character storage. */     private final char value[];      /** The offset is the first index of the storage that is used. */     private final int offset;      /** The count is the number of characters in the String. */     private final int count;      /** 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;      ........ }

从上面可以看出几点:

1)String类是final类,也即意味着String类不能被继承,并且它的成员方法都默认为final方法。

在Java中,被final修饰的类是不允许被继承的,并且该类中的成员方法都默认为final方法。

2)上面列举出了String类中所有的成员属性,从上面可以看出String类其实是通过char数组来保存字符串的。

相关学习推荐:java基础教程

以上就是java中string什么意思的详细内容,更多内容请关注技术你好其它相关文章!

来源链接:
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
标签: string
上一篇:php获取远程图片并下载保存到本地的方法分析 下一篇:零基础学java难么?怎么自学?

相关资讯