-3

I have written two concept for adding or initializing two string just want to know in both concept final str1 reference will be change from starting ?

  1. string str1="A"; str1="B";

  2. string srt1="A"+"B";

Please answer me in concept of stringBuilder

thanks

Kranti Singh
  • 189
  • 2
  • 4
  • 17

1 Answers1

2

strings are immutable, its recommended to avoid direct string concatenation frequently or in a large loop. In your case, impact of performance is nil. look at - String vs. StringBuilder

Community
  • 1
  • 1
Rabi
  • 2,210
  • 17
  • 18