您的位置:首页 > 其它

string 和int 相“+”在System.out.println()

2008-11-12 13:27 197 查看
 

注意其中的微妙不同

public class StringPlusInt {

    public static void main(String[] args) {

        int x=1,y=2,z=3;

        String s="str";

        System.out.println(x+y+z);

        System.out.println(s+x+y+z);

        System.out.println(x+y+z+s);

        System.out.println(s+(x+y+z));

        System.out.println("str2"+x+y+z);

    }

}

结果:

6
str123
6str
str6
str2123
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  string