answersLogoWhite

0


Best Answer

class sortstr

{

public static void main(String args[])

{

int len=args.length;char ch1;

if(len==0)

{

System.out.println("No arguments are given ! ");

return;

}

char[] str=args[0].toCharArray();

char temp;

for(int i=0;i<len;i++)

{

for(int j=0;j<len-1;j++)

{

ch1=str.charAt(j);

char ch2=str.charAt(j+1);

if(ch1> ch2)

{

temp=str[j];

str[j]=str[j+1];

str[j+1]=temp;

}

}

}

for(int i=0;i<len;i++)

{

System.out.print(str[i]);

}

}

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write an java program that reads a collection of words and prints the words in alphabetical order?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write a c program that prints a box an oval an arrow and a diamond?

You first learn how to program in C.


Write a program that input a positive integer and prints a triangle using for loop?

write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?


Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


How do you write a c program to prints name?

Write a c program that reads your first name and surname when you enter them. Each part of your name should not be more than 12 characters. Finally, have the program display your full name.


How can you write a sentence with prints and prince?

The prince has a lot of prints that he printed (iI don't know I know it's dumb)


How do you write a program which reads a list of ten numbers and print the list in reserve order in c program?

The simplest way is probably to read the numbers into an array and then prints each element of the array starting at the last one and moving backwards.


Write a program which reads names of students and their telephones from a file and produce a linked list ordered in alphabetical order by the surname of the student?

write a program which reads names of students and their telephones from a file and produce a linked list ordered in alphabetical order by the surname of the student.


Write a c program for alphabetical order?

int main (void) { puts ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); return 0; }


How do you write a java program to code the applicant collection class which stores and display the personal details of three applicants?

i dont know plz give me the answer


Write a java program that prints all alphabets?

class TestApp { public static void main(String args[]) { char ch; for( ch = 'a' ; ch &lt;= 'z' ; ch++ ) System.out.println(ch); } }


How do you write a letter for remove your finger prints?

Ask a local attorney.


What is Sibelius software used for?

Sibelius is a program on which users write sheet music and can hear it played back to them.