how to concatenate values in string java code example
Example 1: java best way to concatenate strings
// StringBuilder
String stringBuilderConcat = new StringBuilder()
.append(greeting)
.append(" ")
.append(person)
.append("! Welcome to the ")
.append(location)
.append("!")
.build();
Example 2: java concatenate strings
public class Concat {
String cat(String a, String b) {
a += b;
return a;
}
}