社区
Java SE
帖子详情
System.out.print(""+'a'+1)和System.out.print('a'+1)区别?
lianghua19
2009-09-30 11:33:58
为何结果不同?
System.out.print(""+'a'+1)这个为什么输出的是字符串啊?
...全文
373
16
打赏
收藏
System.out.print(""+'a'+1)和System.out.print('a'+1)区别?
为何结果不同? System.out.print(""+'a'+1)这个为什么输出的是字符串啊?
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
16 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
pywepe
2009-09-30
打赏
举报
回复
用了""就会变成String的
接分
hh161151
2009-09-30
打赏
举报
回复
因为前面有个"",所以自然是字符串啊
justinavril
2009-09-30
打赏
举报
回复
1#和2#都回答了 我就不蹭分了 lz结贴吧
hjiea666
2009-09-30
打赏
举报
回复
数值型(包括char型)和字符串相加要自动转换成字符串
andyheway
2009-09-30
打赏
举报
回复
system.out.print().
这个输出的时候会自动的toString()
lxxzhy
2009-09-30
打赏
举报
回复
[Quote=引用 2 楼 fuyou001 的回复:]
System.out.print('a'+1)//会隐式转换成int 98
[/Quote]
.
szlb2008
2009-09-30
打赏
举报
回复
接分飘过
fuyou001
2009-09-30
打赏
举报
回复
System.out.print('a'+1)//会隐式转换成int 98
fuyou001
2009-09-30
打赏
举报
回复
System.out.print(""+'a'+1) //因为你用"" ,所以整个结果都是字符串
charwei
2009-09-30
打赏
举报
回复
因为你用了"",空格加任何数字都是字符串 (""+5+8=58)
zhuzeitou
2009-09-30
打赏
举报
回复
第一个是print(String s)
第二个是print(int i)
dajiadebeibei9
2009-09-30
打赏
举报
回复
因为""是一个字符串 你用+好进行连接,也就是在""之后连接字符串
由于 "a"是字符型 +号会使用字符型自动向字符串类型转换 后面的1就更别说了 也被转换为字符串了
这体现了级别的类型在某些情况下会被自动封装成级别高的类型
wuwenzhe
2009-09-30
打赏
举报
回复
学习了
@井九
2009-09-30
打赏
举报
回复
想输出一样就加个括号吧
System.out.print(""+('a'+1));
shine333
2009-09-30
打赏
举报
回复
"" + 'a'==>"a"
"a" + 1 ==>"a1"
===============
'a' == (char) 97;
'a' + 1 = 97 + 1 = 98
bigbro001
2009-09-30
打赏
举报
回复
第一个例子中,有+""的连接表达式,整个表达式自动升级(auto promotion)成字符串(String)
第二个例子中,含有有整数字面量(integer literal)的连接表达式,字符'a'自动升级成int类型
Java中的输出语句System.out.
pr
int
()和System.out.
pr
int
ln()的
区别
以及\t\r\n\x
System.out.
pr
int
(“a”); System.out.
pr
int
(“a”); 控制台输出结果为: aa System.out.
pr
int
ln(“a”); System.out.
pr
int
ln(“a”); 控制台输出结果为: a a 在打印九九乘法表的时候可能会出现对不齐的情况: ...
2021-08-29 System.out.
pr
int
ln(a++);或者System.out.
pr
int
ln(a--);输出的值不变,而++a或者--a则进行+1或者-1。
System.out.
pr
int
ln(a++);或者System.out.
pr
int
ln(a–);输出的值不变 而System.out.
pr
int
ln(++a);或者System.out.
pr
int
ln(–a);输出的值会+1或者-1 package operater; public class SuanShuYunSuanFu { public ...
System.out.
pr
int
与System.out.
pr
int
ln与System.out.
pr
int
f之间的
区别
System.out.
pr
int
与System.out.
pr
int
ln与System.out.
pr
int
f之间的
区别
分析System.out.
pr
int
ln('i'+1)与System.out.
pr
int
ln(""+'i'+1)的
区别
分析System.out.
pr
int
ln('i'+1)与System.out.
pr
int
ln(""+'i'+1)的
区别
你知道System.out.
pr
int
ln,System.out.
pr
int
(),System.out.
pr
int
f三者的
区别
吗?
Java中常见的输出语句包括System.out.
pr
int
ln() 和System.out.
pr
int
() 三者的
区别
:
pr
int
ln System.out.
pr
int
ln() 输出信息后追加一个换行
pr
int
System.out.
pr
int
()输出之后不追加换行
pr
int
f System.out....
Java SE
62,630
社区成员
307,264
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章