1、
public class StringBufferTest
{
public static void main(String[] args)
{
StringBuffer buffer = new StringBuffer();
buffer.append("hello").append(" world").append(" welcome").append(100).append(false);//等价于 buffer = buffer.append("hello");...
String result = buffer.toString();
System.out.println(result);
String s = "abc";
int a = 100;
boolean b = true;
String str = s + a + b;
System.out.println(str);//结果:abc100true
System.out.println(false + true);//无法编译
}
}
2、包装类Wrapper Class:针对原生数据类型的包装。
所有的包装类(8个)都位于java.lang包下:Byte、Short、Integer、Long、Float、Double、Character、Boolean。
它们的使用方式都是一样的,可以实现原生数据类型与包装类型的双向转换。
public class IntegerTest
{
public static void main(String[] args)
{
int a = 10;
Integer integer = new Integer(a);
Int b = integer.intValue();
System.out.println(a == b);
}
}