String字符串的构造方法
public String() 创建一个空字符串对象
1 String s = new String(); 2 System.out.println("s: " + s);
public String(String original) 创建一个内容为original的字符串对象
1 String s2 = new String("abc"); 2 System.out.println("s2: " + s2);
public String(char[] value) 将字符数组转换成字符串(必须记住)
1 char[] chs = {'a','b','c','d'}; 2 String s3 = new String(chs); 3 System.out.println("s3: " + s3);
public String(char[] value, int index, int count) 将字符数组的一部分转换成字符串
1 String s4 = new String(chs, 1, 2); 2 System.out.println("s4: " + s4);
public String(byte[] bytes) 将字节数组转换成字符串(必须记住)
1 byte[] bys = {97,98,99,100}; 2 String s5 = new String(bys); 3 System.out.println("s5: " + s5);
public String(byte[] bytes, int offset, int length) 将字节数组一部分转换为字符串
1 String s6 = new String(bys, 1, 2); 2 System.out.println("s6: " + s6);