0

1.

String s1 = "Stack";  
String s2 = s1.concat(" Overflow");

2.

String s1 = "Stack";  
String s2 = s1+" Overflow";

Here, how many objects are created in heap and scp in both cases?

vimuth
  • 5,064
  • 33
  • 79
  • 116
amith dino
  • 49
  • 6
  • Maybe its a duplicate with this [link](https://stackoverflow.com/questions/50636396/where-is-the-new-object-of-string-created-when-we-concat-using-operator) question – nandan aggarwal Apr 28 '19 at 05:54
  • this is also discussed here, https://stackoverflow.com/questions/21724072/number-of-objects-created-during-string-concatenation – inesh hettiarachchi Apr 28 '19 at 06:41

0 Answers0