Create a Java program to demonstrate a method with varargs that sorts a sequence of strings
import java.util.Arrays; public class StringSorter { static void sortStrings(String... strings) { System.out.println("Given Strings : " + Arrays.toString(strings)); Arrays.sort(strings); System.out.println("Sorted Strings : " + Arrays.toString(strings)); } public static void main(String[] args) { sortStrings("Pink", "Blue", "White", "Red", "Black", "Green", "Yellow", "Orange"); } }
Given Strings : [Pink, Blue, White, Red, Black, Green, Yellow, Orange] Sorted Strings : [Black, Blue, Green, Orange, Pink, Red, White, Yellow]
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions