Sunday 24 March 2013

A Java Program which will read a String and Rewrite it in the Alphabetical Order.


e.g. The word “STRING” should be written a “GNIRST”.
import java.io.*;
import java.util.*;
class Alphabatic
{
String alphaOrder(String str)
{
char[] charArray=str.toCharArray();
Arrays.sort(charArray);
String aString=new String(charArray);
return aString;
}
public static void main(String[] args)throws IOException
{
System.out.println("Enter the String->");
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
String inputString=br.readLine();
Alphabatic obj=new Alphabatic();
String alphaString=obj.alphaOrder(inputString);
System.out.println("String in the Alphabetic Order :" +alphaString);
}
}

1 comment:

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...