ASCII表以及案例

1、通过一个字符一个整数相加,我们给出一张表取参考结果,这个表叫做ASCII码表

image

​ 示例:

image

2、(1)当字符串数据和其他数据做+(字符串在前,其他数据在后),此时这里的+不是做加法运算,而是字符 串连接符,输出结果依旧是字符串;例如:("hello"+‘a'+1);输出结果为helloa1

​ (2)当其他数据在前,字符串在后,例如('a'+1+"hello"+'a'+1);输出结果为98helloa1

​ 示例:

image

​ System.out.println('a');-----------------------------结果为:a

​ System.out.println('a'+1);-------------------------结果为:98

​ System.out.println("hello"+'a'+1);--------------结果为:helloa1

​ System.out.println('a'+1+"hello");--------------结果为:98hello

​ System.out.println("5+5="+5+5);---------------结果为:5+5=55

​ System.out.println(5+5+"=5+5");---------------结果为:10=5+5

posted @ 2021-11-24 20:30  阿伟宝座  阅读(511)  评论(0)    收藏  举报