Q:

String Ascending Order using Java Program

0

This Program is used to calculate String Ascending Order Program using Java.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

// arrange the strings in ascendin order 

class ssva 
{ 
public static void main(String arg[]) 
{ 
String s[],t; 
s=new String[5]; 
s[0]="senthil"; 
s[1]="velan"; 
s[2]="vicky"; 
s[3]="kumutha"; 
s[4]="vignesh"; 
int i,j; 

for(i=0;i<s.length-1;i++) 
{ 
for(j=i+1;j<s.length;j++) 
if(s[i].compareTo(s[j])>0) 
{ 
t=s[i]; 
s[i]=s[j]; 
s[j]=t; 
} 
} 
for(i=0;i<s.length;i++) 
System.out.println(s[i]); 
} 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now