For the println statement, I guess the + operator doesn't convert the math return value until that value is computed. And at that point, it is converted to a string.
If the println statement was to read:
<pre>class Abstest {
public static void main(String[] args) {
System.out.println("Output1: " + Math.round(Math.random())*(10));
System.out.println("Output2: " + Math.round(Math.random())+(10));
}
}</pre>
...then it should multiply the rounded # by 10 before converting it to a string for Output1 and for Output2 it will convert the rounded value to a string and then append the value of 10 as a string to the end.
All this is true.
The problem I was having on the println portion was realizing that the type of operator precedence makes a difference in how the overridden + operator treats values after a string. If I'm off base here...please correct me.
"the type of operator precedence"? Perhaps I'm just too tired, but I'm not following you.
Java evaluates each expression between the '+' signs before it calls toString() on any of them. Then it goes left to right.
"Output1: " + Math.round(Math.random())*(10)
String + number.toString()
"Output2: " + Math.round(Math.random())+(10)
String + number.toString() + number.toString()
is not the same as
String + (number + number).toString()
In the second case the numbers are added together first because the parens have higher precedence.