I have written a custom method to use StringBuilder in java. My Requirement is to create a method which accepts any number of arguments of any type and return String by concatenating the arguments.
eg. msgBuilder("Hello ",0," how"," are"," you ",2.5) return "Hello 0 how are you 2.5"
Here is my java code. Please Someone review my code and suggest If I did anything is wrong or Can I use this further in my projects.
public class Test { public static void main(String[] args ){ String msg = msgBuilder("Hello ",5," How ","are ","you"); System.out.println(msg); } private static String msgBuilder(Object... params){ StringBuilder sb = new StringBuilder(); for(Object obj:params){ sb.append(obj); } return sb.toString(); } }
String
formatting, have you checked if your logging framework of choice has it? Also, are you on Java 8?\$\endgroup\$