Elegant Solutions to the Fencepost Problem (with Strings)
问题 What I'm referring to is concatenating String s with a certain String in the middle, such as concatenating sentences separated by a period, or parameter lists with a comma. I know you can use libraries, but sometimes these can't do what you want, like when you want to generate the phrases you are concatenating. So far I've come up with two solutions, StringBuffer sentence = new StringBuffer(); String period = ""; for ( int i = 0; i < sentences.length; i++ ) { sentence.append( period +