什么是Java String的默认初始值? [英] What is a Java String's default initial value?

查看:870
本文介绍了什么是Java String的默认初始值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑名为 x 的Java字符串字段。
为类x创建对象时, x 的初始值是什么;

Consider a Java String Field named x. What will be the initial value of x when an object is created for the class x;

我知道对于 int 变量,默认值被指定为 0 ,因为正在创建实例。但是什么变成字符串

I know that for int variables, the default value is assigned as 0, as the instances are being created. But what becomes of String?

推荐答案

如果你将它初始化为null什么都不做,就像所有参考类型一样。

It's initialized to null if you do nothing, as are all reference types.

这篇关于什么是Java String的默认初始值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆