multiple strings in java

Java Easy
✅ Solved
Asked by Neelkumar Gohil Feb 03, 2026 at 05:05 Subject: Java Programming

Question:

WAP to accept multiple strings and arrange them in ascending order

💬 0 Comments 💡 1 Solution(s)

💡 Solutions (1)

Super Admin

Admin

Feb 09, 2026 at 07:24

👍 0

upvotes

//WAP to accept multiple strings and arrange them in ascending order import java.util.Scanner; import java.util.Arrays; class StringSort { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter number of strings: "); int n = sc.nextInt(); sc.nextLine(); // clear buffer String[] arr = new String[n]; System.out.println("Enter strings:"); for (int i = 0; i < n; i++) { arr[i] = sc.nextLine(); } // Sorting strings in ascending order Arrays.sort(arr); System.out.println("\nStrings in ascending order:"); for (String s : arr) { System.out.println(s); } sc.close(); } }

👍 Login to Vote

Want to add your solution? Login to contribute!

💬 Comments (0)

Login to post comments

No comments yet

Be the first to comment!