string

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

Question:

WAP to accept a string and rewrite it in alphabetical order. e.g. COMPUTER --- > CEMOPRTU

💬 0 Comments 💡 1 Solution(s)

💡 Solutions (1)

✅ ACCEPTED SOLUTION

Super Admin

Admin

Feb 09, 2026 at 07:35

👍 0

upvotes

import java.util.Scanner; import java.util.Arrays; class AlphabeticalOrder { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter a string: "); String str = sc.nextLine(); // Convert string to character array char[] ch = str.toCharArray(); // Sort characters Arrays.sort(ch); // Convert back to string String result = new String(ch); System.out.println("Alphabetical order: " + result); 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!