아까 질문글 올렸는데 정리.
1. println(object x) 메소드.
This method calls at first String.valueOf(x) to get the printed object's string value, then behaves as though it invokes print(String) and then println().
https://docs.oracle.com/javase/8/docs/api/java/io/PrintStream.html#println--
x의 value를 모두 치환해주긴함.
2. 근데 println에 들어가는 파라미터 자체가 1+ 1+ "123" 이런경우는 어쩌라는거냐?
If only one operand expression is of type String, then string conversion is performed on the other operand to produce a string at run time.
https://docs.oracle.com/javase/specs/jls/se15/html/jls-15.html#d5e29894
만약 한 피연산자가 string 타입이라면, string conversion이 런타임에서 일어남. (String Concatenation Operator)
string 합친 결과는 두개의 string을 합친 레퍼런스가 되고.
3. 번외 : string 합쳐지는 순서.
왼쪽부터 -> 오른쪽
괄호 있으면 괄호 먼저
1 : 1 + 1 + "123"
2: 2 + "123"
3: "2123"
오늘도 궁금증 해결!
(std::ostringstream()<< 1 << 1 << "123").str() - 디씨 앱
c++이 더 직관적이네요