Home >Java >javaTutorial >The difference between string and char in java

The difference between string and char in java

(*-*)浩
(*-*)浩Original
2019-12-27 09:25:058511browse

The difference between string and char in java

1. Different types

char is a character type and String is a string type. (Recommended learning: java course)

2. Contains

String string is used to contain strings, char is used to contain Single character.

For example:

char a='1';//定义一个字符
String b="dadsa";//定义一个字符串

3. Storage

The result used to store internally in String is a char character array.

private final char value[];//这是string中用来存储值的结构。

4. Definition

char is defined with single quotes and can only have one alphanumeric character.

String is defined with double quotation marks. It can be one or more letters or Chinese characters, which is the so-called string.

The difference between string and char in java

The above is the detailed content of The difference between string and char 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