Java 中的"+"号(加法和连接)

Java 中的"+"号(加法和连接)

public class Test {
    public static void main(String[] args) {
        System.out.println(2 + 0 + 1 + 6 + "GeeksforGeeks");
        System.out.println("GeeksforGeeks" + 2 + 0 + 1 + 6);
        System.out.println(2 + 0 + 1 + 5 + "GeeksforGeeks" + 2 + 0 + 1 + 6);
        System.out.println(2 + 0 + 1 + 5 + "GeeksforGeeks" + (2 + 0 + 1 + 6));
    }
}

参考答案

9GeeksforGeeks
GeeksforGeeks2016
8GeeksforGeeks2016
8GeeksforGeeks9

猜你喜欢

转载自www.cnblogs.com/hglibin/p/11404527.html