char的默认值是多少? [英] what's the default value of char?

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

问题描述

  char c ='\\\'; 

当我打印c时,它在命令行窗口中显示'a'。



那么char类型字段的默认值是什么?



有人说'\\\'在unicode中表示null;是

解决方案

char 属性的默认值确实是'\\\'(空字符),如Java语言规范中的§4.12.5变量的初始值



我的系统,行 System.out.println('\\\'); 打印一个小方块,这意味着它不是一个可打印的字符。 >

char c = '\u0000';

When I print c, it shows 'a' in the command line window.

So what's the default value of a char type field?

Someone said '\u0000' means null in unicode; is that right?

解决方案

The default value of a char attribute is indeed '\u0000' (the null character) as stated in the Java Language Specification, section §4.12.5 Initial Values of Variables .

In my system, the line System.out.println('\u0000'); prints a little square, meaning that it's not a printable character - as expected.

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

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