Concatenates infinite number of strings using a StringBuilder - Android java.lang

Android examples for java.lang:StringBuilder

Description

Concatenates infinite number of strings using a StringBuilder

Demo Code


public class Main{

    /**/*from   ww  w.  ja  v a 2s  . c  om*/
     * Concatenates infinite number of strings using a StringBuilder.
     * 
     * @param strings Arbitrary number of strings
     * @return Concatenated string
     */
    public static String concat(String... strings) {

        StringBuilder stringBuilder = new StringBuilder();

        for (String string : strings) {
            stringBuilder.append(string);
        }

        return stringBuilder.toString();
    }

}

Related Tutorials