我试图更好地理解字符串.我基本上是在制作一个需要大量字符串的程序.但是,很多字符串非常非常相似,只需要在字符串末尾使用不同的单词.
例如
String one = "I went to the store and bought milk" String two = "I went to the store and bought eggs" String three = "I went to the store and bought cheese"
所以我的问题是,在处理字符串时最适合采用哪种方法?将2个字符串连接在一起有什么好处而不仅仅是静态字符串,例如性能或内存管理?
例如
String one = "I went to the store and bought " String two = "milk" String three = "cheese" String four = one + two String five = one + three
我只想弄清楚处理所有这些字符串的最佳方法.(如果它有助于放置我正在使用的一些字符串,我目前有50个,但这个数字可以盈余很多)