2022-09-25 11:35阅读: 14评论: 0推荐: 0

代码阅读题-空对象

public static void main(String[] args) {
String s="";
System.out.println(s==null);
int[] arr = new int[]{};
System.out.println(arr==null);
List<Integer> list = new ArrayList<>();
System.out.println(list.size());
}

输出:

false
false
0

空对象也分配了内存地址

本文作者:YaosGHC

本文链接:https://www.cnblogs.com/yaocy/p/16727542.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   YaosGHC  阅读(14)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起