Write a Java program to demonstrate a method with varargs that concatenates a specific string with a variable number of strings
public class StringAppender { static String appendString(String base, String... strings) { StringBuilder result = new StringBuilder(base); for (String str : strings) { result.append(str); } return result.toString(); } public static void main(String[] args) { String finalString = appendString("Hello, ", "Java ", "Programmers ", "World!"); System.out.println("Concatenated String : " + finalString); } }
Concatenated String : Hello, Java Programmers World!
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions