Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The difference between java character constant and string constant

Shulou Source: shulou.com Published: 2022-06-02 04:18:08 10月03日 Update

This article mainly explains the difference between java character-type constant and string constant. The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the difference between java character-type constant and string constant.

What is the difference between a character constant and a string constant?

Formally: a character constant is a character enclosed in single quotation marks; a string constant is a number of characters enclosed in double quotation marks

In meaning: the character constant is equivalent to an integer value (ASCII value) and can participate in the expression operation; the string constant represents an address value (the string is stored in memory)

The character constant occupies only 2 bytes of memory size; the string constant takes up several bytes (note: char takes up two bytes in Java)

Thank you for your reading, the above is the content of "the difference between java character-type constant and string constant". After the study of this article, I believe you have a deeper understanding of the difference between java character-type constant and string constant. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Character constant string character type byte learning memory content quotation marks two representation location meaning address size that is form idea situation article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Linux Microsoft Redmi NVidia