当前位置:网站首页>String s = null ; String s = new String();String s =““ ;String s ;有什么区别?
String s = null ; String s = new String();String s =““ ;String s ;有什么区别?
2022-06-12 17:10:00 【积分中值定理】
1.String s =null ;
未申请任何内存资源,只是声明了对象的引用,并没有把对象真正的实例化出来,仅仅是把栈内存的String引用指向了一个null,表示声明了一个引用变量并初始化引用,但是该引用没有指向任何对象.但可以把它作为参数传递或其它使用,但是不能调用它作为对象的方法。
2.String s ="" 和String s = new Stirng();
是真正的把对象创造出来,并把对象放到堆内存里。String s=""; 表示申请了内存资源,但资源空间值为空。该语句表示声明并引用到一个对象,只不过这个对象为0个字节.所以既然有了对象,就可以调用对象的方法。
3.String s ;
该语句表示只是声明了一个引用变量,但是并没有初始化引用,所以对变量s的任何操作(除了初始化赋值外) 都将引发异常。
边栏推荐
- Google browser debugging skills
- Picture online collection and delivery system source code
- 薛定谔的日语学习小程序源码
- Recommend 6 open source projects of yyds
- (6) Control statement if/else switch
- 快速入门scrapy爬虫框架
- (七)循环语句for
- R语言使用epiDisplay包的summ函数计算dataframe中指定变量在不同分组变量下的描述性统计汇总信息并可视化有序点图(名称、有效值个数、均值、中位数、标准差、最大值、最小值)
- 怎么在公司里面做好测试工作(做好测试工作)
- Tidb Hackathon 2021 - pcloud: conduct icloud pcloud team interview on the database
猜你喜欢

两位新晋Committer的“升级攻略”

Unit sshd. service could not be found

Hangzhou AI developer meetup registration opens!

2080 virtual machine login command

云开发坤坤鸡乐盒微信小程序源码

Atlassian Confluence 远程代码执行漏洞(CVE-2022-26134)漏洞复现

Gerrit triggers Jenkins sonarqube scan

Sudo of uabntu

Qt开发高级进阶:初探qt + opengl

使用GCC的PGO(Profile-guided Optimization)优化整个系统
随机推荐
Saturated! Can't future programmers work anymore?
The safety of link 01 was questioned, and "ultra high strength" became "high strength"_ Publicity_ Steel_ problem
(八)goto关键字
R语言使用ggplot2可视化dataframe数据中特定数据列的密度图(曲线)、并使用xlim参数指定X轴的范围
1723. minimum time to complete all work
云开发坤坤鸡乐盒微信小程序源码
Atlassian Confluence 远程代码执行漏洞(CVE-2022-26134)漏洞复现
(4) Golang operator
性能优化之编译优化
Guitar Pro tutorial how to set up a MIDI keyboard
Sudo of uabntu
Concurrent trichromatic marking
Microsoft Office MSDT Code Execution Vulnerability (cve-2022-30190) vulnerability recurrence
价值超高的CA证书解析
Go variables
Quick start sweep crawler framework
STL -- function object
Play kubernetes every 5 minutes summary
The R language uses the pyramid function of epidisplay package to visualize the pyramid graph and the pyramid graph based on the existing summary data (table data)
淘宝Native研发模式的演进与思考 | DX研发模式