Java 中字符字面量和字符串字面量有什么区别?
字符字面量表示字母(大小写)、数字(0 到 9)、特殊字符(@、?、& 等)和
,\b 等转义序列。
而字符串字面量表示 String 类的对象。
范例
public class LiteralsExample {
public static void main(String args[]){
char ch = 'H';
String str = "Hello";
System.out.println("Value of character: "+ch);
System.out.println("Value of string: "+str);
}
}
输出
Value of character: H Value of string: Hello
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP