Create a Java program using a method with varargs to concatenate a set of strings in reverse order
import java.util.Arrays; public class ReverseStringConcatenator { static String concatenateReverse(String... strings) { System.out.println("Given String : " + Arrays.toString(strings)); StringBuilder result = new StringBuilder(); for (int i = strings.length - 1; i >= 0; i--) { result.append(strings[i]); } return result.toString(); } public static void main(String[] args) { String reversedString = concatenateReverse("Red", "Blue", "Green"); System.out.println("Reversed Concatenated String : " + reversedString); } }
Given String : [Red, Blue, Green] Reversed Concatenated String : GreenBlueRed
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions