字符串和数字的运算

1.字母  与字母所代表的值进行运算、

  'A' = 65

  'a' = 97

  '0' = 48

2.字符串与数字‘+’运算是拼接,顺序不同影响结果

 1 public class Operator1{
 2     public static void main(String[] args){
 3         int a = 10;
 4         int b = 20;
 5         char c = 'A';
 6     
 7         System.out.print(a + c );    //65
 8         System.out.println('hello' + a + b);        //hello1020
 9         System.out.println(a + b + 'hello');        //30hello
10     }
11 }

猜你喜欢

转载自www.cnblogs.com/yifengs/p/10658038.html