- <P>public class Test {
- public static void main(String[] args) {</P>
- <P>String s = "1234";
- String s0 = "1\2\3\4";
- String s1 = "1\\2\\3\\4";
- String s2 = "1\\d2\\d3\\d4";</P>
- <P>//String s2 = "1\d2\d3\d4";报编译错误?为什么?\d不是转义字符吗?
- String s3= "1\t2\t3\t4";</P>
- <P>System.out.println(s0.length()); //4
- System.out.println(s0.length()); //4 字符串s0中的 \ 没占内存吗?
- System.out.println(s1.length()); //7
- System.out.println(s2.length()); //10
- System.out.println(s3.length()); //7
- }</P>
- <P> </P>
- <P>}</P>
复制代码 求高手解答以上输出结果?谢谢
|