Why is toString() not implicitly called?
Posted: Wed Jan 27, 2016 12:13 pm
In the following code:
The correct answer given is that it does not compile. However, I have seen many instances where an object is passed into the println and there is an implicit call to it's toString(). What am I not understanding here?
Thanks!
Code: Select all
StringBuilder sb = new StringBuilder("8");
int i = 8;
System.out.println(8 + i + sb);
Thanks!