字符与字符串的参与运算

字符参与运算: char --> int , 去查ASCII码表 ;

'a' ---> 97 , 'A' ---> 65 , '0' ---> 48

 


字符串参与运算

任何数和字符串进行相加,得到的结果都是一个新的字符串

+ 表示的是字符串连接符

 


    • 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 on 2017-02-15 20:25  LoaderMan  阅读(533)  评论(0编辑  收藏  举报

导航