Professional Documents
Culture Documents
Write a java program to input a String and print all the characters of the string in
alphabetical order
INPUT :- ALARM
OUTPUT :- AALMR
Ans:
/**
* Write a program in Java to accept a string. Arrange all the letters of the string in an alphabetical order.
*/
import java.util.Scanner;
System.out.println("Enter a string:");
str = str.toLowerCase();
if (ch == strCh) {
sortedStr += strCh;
}
System.out.println("Alphabetical order:");
System.out.println(sortedStr);
Output:
Enter a string:
Rounak
Alphabetical order:
Aknoru