Java初涉之1--Java中的 "+"

来源:互联网 发布:js 判断invalid date 编辑:程序博客网 时间:2024/06/01 09:22
package day01;public class Test {    public static void main(String[] args) {        // TODO Auto-generated method stub        String s1 = "abc";        int a = 1;        int b = 2;        int c = 3;        System.out.println(a+b+c+s1);//6abc        System.out.println(s1+a+b+c);//abc123        System.out.println(a+b+s1+c);//3abc3    }

It is easy to detect that when the first is not the string ,so “+” do as the mathematical operator.If the first is string ,so “+” from this to end is string concatenation.

Tips:
mathematical operator :数学运算符
string concatenation:字符串连接
concatenation[kənkætə’neɪʃn]: A concatenation of things or events is a series of them linked together. 连结

0 0
原创粉丝点击