Home > Java > javaTutorial > body text

The difference between string and char in java

(*-*)浩
Release: 2019-12-27 09:25:05
Original
8474 people have browsed it

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";//定义一个字符串
Copy after login

3. Storage

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

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template