当前位置:网站首页>String s = new string ("XYZ") how many string objects are created?
String s = new string ("XYZ") how many string objects are created?
2022-06-24 00:01:00 【The fifth brother of the Wang family】
One or two . If the string constant pool already has “xyz”, It is a ; otherwise , Two .
When the character creation constant pool does not “xyz”, The following two objects will be created :
One is the literal amount of a string "xyz" The corresponding 、 Resident (intern) Instances in a globally shared string constant pool , At this time, the instance is also in the heap , String constant pool only puts references .
The other is through new String() Create and initialize , Content and "xyz" Same instance , It's also in the heap .
String s = "xyz" and String s = new String("xyz") difference ?
Both statements will first go to the string constant pool to check whether it already exists “xyz”, If so, use , If not, the... Is created in the constant pool “xyz” object .
in addition ,String s = new String("xyz") Will pass new String() Create a content and in the heap "xyz" Same object instance .
So the former is actually understood as being included by the latter .
边栏推荐
- 工作中一些常用的工具函数
- 图扑软件智慧风电:数字孪生 3D 风机智能设备运维
- Solve the problem of project dependency red reporting
- 生成所有可能的二叉搜索树
- 【 GBASE的那些事儿】系列直播活动第02期《GBase 8s高可用技术及案例分析法》
- Flux in three dimensional vector field
- fatal: The upstream branch of your current branch does not match the name of your current branch.
- Another short video app with high imitation and eye opening
- Total number of combinations ii[each element can only be solved by + once]
- 不容错过 | 华为内部资料--成功的项目管理PPT(123页)
猜你喜欢

Docker redis cluster configuration

SQL Server 中 GO 的用法

Loop caused by add of sublist in list

B2B transaction management system of electronic components industry: improve the data-based driving ability and promote the growth of enterprise sales performance

Startup process analysis of APP performance optimization

fatal: The upstream branch of your current branch does not match the name of your current branch.

云原生架构(05)-应用架构演进

三维向量场中的通量

Visual explanation of clockwise inner curve in Green's formula hole digging method
![Total number of combinations ii[each element can only be solved by + once]](/img/06/a40e28a1882a4278883202bc9c72d3.png)
Total number of combinations ii[each element can only be solved by + once]
随机推荐
fatal: The upstream branch of your current branch does not match the name of your current branch.
fatal: The upstream branch of your current branch does not match the name of your current branch.
MySQL architecture (basic)
WPF效果之Expander+ListBox
Facebook open source shimmer effect
Web site SSL certificate
C语言c89(c90)的所有的32个关键字分类
Kubernetes basic concept
List<? Extensions T > and list <? Super T > difference
Detailed explanation of index invalidation caused by MySQL
Notepad++实用功能分享(正则行尾行首替换常用方法、文本比对功能等)
.NET 中的 Worker Service 介绍
Goodbye, 2020, this bowl of poisonous chicken soup, I'll dry it first
Idea automatically generates unit tests, doubling efficiency!
Graph theory (nearest common ancestor LCA)
log Network Execution Time
Gbase observation: extended analytical database
The group procurement management system of daily chemical supplies industry changes the traditional procurement mode and reduces the procurement cost
Differences between broadcastreceiver and localbroadcastmanager
Test - use case - detail frenzy