为了账号安全,请及时绑定邮箱和手机立即绑定

输出带+号问题

为什么下面的程序输出带加号时输出的是ASCII值,而不到加号时正确输出;

还有为什么

http://img1.sycdn.imooc.com//5962231e00013a7906500523.jpg

http://img1.sycdn.imooc.com//5962231f00013c1906350529.jpg

当我定义数组的类型为字符串时输出带加号时语法错误

正在回答

2 回答

public void print(char s[]) {
   write(s);
}

/**
* Prints a string.  If the argument is <code>null</code> then the string
* <code>"null"</code> is printed.  Otherwise, the string's characters are
* converted into bytes according to the platform's default character
* encoding, and these bytes are written in exactly the manner of the
* <code>{@link #write(int)}</code> method.
*
* @param      s   The <code>String</code> to be printed
*/

0 回复 有任何疑惑可以回复我~
#1

wwwwfm 提问者

这些是什么,看不懂
2017-07-11 回复 有任何疑惑可以回复我~

我也是新手

char a = 'a';
char b = 'b';
System.out.println(a);
System.out.println(a+ b);

输出

a

195

两个char相加就是ASCII相加。应该是有+就转成int了吧...

不行就去查查源代码

1 回复 有任何疑惑可以回复我~
#1

啦啦啦啦啦被人占用啦

哦 没仔细看问题。 应该是System.out.print函数里有写吧
2017-07-09 回复 有任何疑惑可以回复我~
#2

wwwwfm 提问者 回复 啦啦啦啦啦被人占用啦

有写的
2017-07-11 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Java入门第一季(IDEA工具)升级版
  • 参与学习       1166248    人
  • 解答问题       17590    个

0基础萌新入门第一课,从Java环境搭建、工具使用、基础语法开始

进入课程

输出带+号问题

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号