search
HomeJavajavaTutorialWhat data type is string?

What data type is string?

Jun 03, 2019 pm 03:49 PM
java

Storage principle of reference types: Reference types inherit from the Object class (also reference types) and store data according to the memory model of storing objects in Java. This type of data is stored using the Java memory heap and memory stack. Storage, simply put, "references" are stored on the ordered memory stack, while the value of the object itself is stored on the memory heap;

What data type is string?

Difference: The difference between basic data types and reference types is mainly that basic data types are allocated on the stack, while reference types are allocated on the heap (requiring the concepts of stack and heap in Java),

What data type does string string belong to in Java?

String in Java is a reference data type. Because String is a class.

Note: String class is immutable, so once you create a String object, its value cannot be changed (see the notes section for details).

The String class has 11 construction methods. These methods provide different parameters to initialize the string, such as providing a character array parameter:

public class StringDemo{
   public static void main(String args[]){
      char[] helloArray = { 'r', 'u', 'n', 'o', 'o', 'b'};      
      String helloString = new String(helloArray);  
      System.out.println( helloString );   
      }
}

The compilation and running results of the above example are as follows:

runoob

The difference between the two ways of creating a string object

The direct assignment method creates the object in the constant pool in the method area

String str="hello";//直接赋值的方式

The string object created through the construction method is in the heap memory

String str=new String("hello");//实例化的方式

The above is the detailed content of What data type is string?. 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools