标签:不可变 har 一个 程序 jpg 文字 idt `` 类型
char c1 = ‘A‘;
char c2 = ‘中‘;
int n1 = c1;//65
int n2 = c2;//20013
System.out.println(n1+"\t"+n2);
System.out.println(Integer.toHexString(n1)+"\t"+Integer.toHexString(n2));
//注意是16进制
char c3 = ‘\u0041‘;
char c4 = ‘\u4e2d‘;
System.out.println(c3+"\t"+c4);
定义字符串:String name;
String s1 = "ABC";//3
String s2 = "中文str";//5
String s3 = "Hello\n";//6
String s4 = "\"Hello\"";//7
System.out.println(s1.length());
System.out.println(s2.length());
System.out.println(s3.length());
System.out.println(s4.length());
String s= "hello";
System.out.println(s);
String h = "hello, "+ "world!";
System.out.println(h);
String a = "age is "+ 12;
System.out.println(a);
所有的引用类型都可以指向空值null,即不指向任何对象。
空字符串和空值不一样
String a = null;
String b = "";
System.out.println("a:"+a);
System.out.println("b:"+b);
标签:不可变 har 一个 程序 jpg 文字 idt `` 类型
原文地址:https://www.cnblogs.com/csj2018/p/10247099.html