How does System.out.print() work?

后端 未结 9 2222
鱼传尺愫
鱼传尺愫 2020-11-27 03:40

I have worked with Java for a quite a long time, and I was wondering how the function System.out.print() works.

Here is my doubt:

Being a functi

9条回答
  •  眼角桃花
    2020-11-27 04:45

    It is a very sensitive point to understand how to work System.out.print. If the first element is String then plus(+) operator works as String concate operator. If the first element is integer plus(+) operator works as mathematical operator.

    public static void main(String args[]) {
        System.out.println("String" + 8 + 8); //String88
        System.out.println(8 + 8+ "String"); //16String
    }
    

提交回复
热议问题