字符 与 字符串Characters and Strings

字符Characters

分析题

参考 ASCII 码表格

ASCII 表

远古小字典

分析下面几段代码的运行结果是什么

1.
1 2 3 4 5
public void run() { int z = 8; int x = 1; Console.println(z - x);}
答案

7

2.
1 2 3 4 5
public void run() { int z = 8; int x = 1; Console.println('z' - x);}
答案

121

3.
1 2 3 4 5
public void run() { int z = 8; int x = 1; Console.println('z' - 1);}
答案

121

4.
1 2 3 4 5
public void run() { int z = 8; int x = 1; Console.println((char)('z' - 1));}
答案

y

5.
1 2 3 4 5
public void run() { int z = 8; int x = 1; Console.println('z' - '1');}
答案

73

6.
1 2 3 4 5
public void run() { int z = 8; int x = 1; Console.println('z' - 'x');}
答案

2

字符串 拼接与构建String Concatenation

路径分析 Java 版

Q55

ZZAX 微信公众

文档一更新,立刻告诉你