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 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!