Home  >  Article  >  Java  >  What does string mean in java

What does string mean in java

little bottle
little bottleOriginal
2019-05-20 14:25:4644728browse

What does string mean in java

Java is an object-oriented programming language, which contains a variety of nouns, all with different meanings.

String in Java means string. When a string variable is declared, data can be stored in it.

String class

If you want to understand a class, the best way is to look at the implementation source code of this class. Take a look at the source code of the String class:

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;

    ........
}

A few points can be seen from the above:

1) The String class is a final class, which means that the String class cannot be inherited, and its member methods default to final methods.

In Java, a class modified by final is not allowed to be inherited, and the member methods in the class are final methods by default.

2) The above lists all the member attributes in the String class. From the above, it can be seen that the String class actually saves strings through char arrays.

Related learning recommendations: java basic tutorial

The above is the detailed content of What does string mean in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn