Skip to main content
edited tags; edited title
Link
Jonas
  • 130.5k
  • 103
  • 330
  • 408

What actually happens in the compiler in this case with StringBuilder?

deleted 6 characters in body
Source Link
Maroun
  • 96.3k
  • 30
  • 195
  • 249

I have a small question, given the following snippet:

StringBuilder stringBuild = new StringBuilder(3);  stringBuild.append("hello");  System.out.println(stringBuild+2); // if I omit the (+2) bit hence only stringBUild it works 

Does it call automatically toString() on object only in some circumstances? (circumstances: either no operation at all or a previous string contatanation)

I have a small question, given the following snippet:

StringBuilder stringBuild = new StringBuilder(3);  stringBuild.append("hello");  System.out.println(stringBuild+2); // if I omit the (+2) bit hence only stringBUild it works 

Does it call automatically toString() on object only in some circumstances? (circumstances: either no operation at all or a previous string contatanation)

I have a small question, given the following snippet:

StringBuilder stringBuild = new StringBuilder(3); stringBuild.append("hello"); System.out.println(stringBuild+2); // if I omit the (+2) bit hence only stringBUild it works 

Does it call automatically toString() on object only in some circumstances? (circumstances: either no operation at all or a previous string contatanation)

Source Link
Rollerball
  • 13.2k
  • 26
  • 99
  • 169

What actually happens in the compiler in this case

I have a small question, given the following snippet:

StringBuilder stringBuild = new StringBuilder(3); stringBuild.append("hello"); System.out.println(stringBuild+2); // if I omit the (+2) bit hence only stringBUild it works 

Does it call automatically toString() on object only in some circumstances? (circumstances: either no operation at all or a previous string contatanation)