1.把字符串转换成字节数组getBytes()
byte[] by = s.getBytes();
for(int x=0;x<by.length;x++){
System.out.print(by[x]+"\t");
}
System.out.println();
2.把字符串转换成字符数组toCharArray()
char[] ch = s.toCharArray();
for(int x=0;x<ch.length;x++){
System.out.print(ch[x]+"\t");
}
System.out.println();
3.把任意类型转换成字符串valueOf()
int x = 42;
System.out.println(s.valueOf(x));
4.把字符串变成小写原字符串不变toLowerCase()
System.out.println(s.toLowerCase());
System.out.println(s);
5.把字符串变成大写原字符串不变toUpperCase()
System.out.println(s.toUpperCase());
6.字符串链接concat()
System.out.println(s.concat("Fanrong")); |
|