当前位置:网站首页>String不同创建方式的区别
String不同创建方式的区别
2022-06-29 03:57:00 【梦中千秋】
例子
public static void main(String[] args) {
String str1 = "aaa";
String str2 = "aaa";
System.out.println(str1 == str2);
String str3 = new String("aaa");
String str4 = new String("aaa");
System.out.println(str3 == str4);
}
我们知道 == 比较引用类型是比较的引用地址,可以发现第一个输出true,第二个输出false,这是因为str1和str2都指向字符串常量池中的 “aaa” 的引用地址 , 而str3和str4 创建了一个新对象 ,“凡是new出来的都存在堆(Heap)内存中”,是在堆内存中的, 不一样的引用地址。
边栏推荐
- 人大金仓(KingBase)导出表结构
- 分布式id解决方案
- 基于可变参模板实现的线程池
- DevOps笔记-05:IT行业中BA、SM、PO、PM、PD、Dev、Ops、QA都是什么角色
- [tcapulusdb] I wish you all a healthy Dragon Boat Festival!
- [tcapulusdb knowledge base] modify business modify cluster
- 谁家的加密密钥,写死在代码里?(说的就是你)
- 2022年 6月27号 《暑假感悟篇一》路程的选择权。
- webassembly学习-动态链接
- PostgreSQL 出现cross-database references are not implemented的bug
猜你喜欢
随机推荐
Data collection and management [7]
Inventory deduction based on redis
VG4131SxxxN0S1无线模块硬件规格书
Draft competition process of Intelligent Vision Group
多机局域网办公神器 rustdesk 使用强推!!!
Data collection and management [12]
人大金仓(KingBase)导出表结构
Kingbase export table structure
NotImplementedError: Could not run torchvision::nms
[tcapulusdb knowledge base] Introduction to tcapulusdb restrictions
How to keep database and cache consistent
sink端 一般都是jdbc的insert update delete么?
Whose encryption key is written in the code? (that's you)
Implementing mqtt communication with PHP
CANoe-如何在Trace窗口解析报文并显示信息(Program Node和结构体类型系统变量的使用)
干货丨微服务架构是什么?有哪些优点和不足?
Adelaidet (detectron2) & abcnet environment configuration
点云地图导入gazebo思路
大神们 在富函数的open中从mysql连接池里取连接 连接池初始化是20个 如果富函数的并行度是1
科技雲報道:混合辦公的B面:安全與效率如何兼得?









