OnJava8-Examples/strings/WhitherStringBuilder.java

19 lines
429 B
Java
Raw Normal View History

2015-04-20 15:36:01 -07:00
//: strings/WhitherStringBuilder.java
public class WhitherStringBuilder {
public String implicit(String[] fields) {
String result = "";
2015-05-18 23:05:20 -07:00
for(String field : fields) {
2015-05-05 14:05:39 -07:00
result += field;
}
2015-04-20 15:36:01 -07:00
return result;
}
public String explicit(String[] fields) {
StringBuilder result = new StringBuilder();
2015-05-18 23:05:20 -07:00
for(String field : fields) {
2015-05-05 14:05:39 -07:00
result.append(field);
}
2015-04-20 15:36:01 -07:00
return result.toString();
}
} ///:~