JavaSE 第三十一讲 Java数组剖析 10.18

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);
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容