Home>

Learning java bronze.

There were the following in the problem collection.

** System.out.print ((3 + 6 * 8/2) + "");// 27

System.out.print (++ a * b ++ + "");// 4 * 5 = 20 **

This is the +""part of the problem, but I recognize that the number is a string,

What about it?

I asked a question because it was not described in the commentary.

  • Answer # 1

      

    Recognizes that the number is a string

    I think that recognition is good.
    Actually, sinceSystem.out.printis used, there is no line break
    Perhaps the real reason is to separate them with spaces.

    Additional
    System.out (PrintStream) print is print (int) or
    print (String), print (char), etc. are overloaded.
    Looking at the first question of the questioner,
    Is print (int) converted to call print (String)?
    It has been confirmed the contents.

    The answer is that it is recognized as a conversion method of creating a character string by concatenating a numeric value and a character string.
    * A common method is to add an empty character ("").

    Why is this conversion carried out on top of that?

      

    Because there are no line breaks, maybe the real reason is to separate them with spaces

    I answered

    .

  • Answer # 2

      

    This is the +""part of the problem, but I understand that the number is a string
      What about it?

    First,""is not a number but a string.
    ""generates a single space. It is concatenated by(3 + 6 * 8/2)and+in front of it.