Preview:
import java.util.*;

class labtask10 

{ 

static String a[],t;

static int n,i,j;

public static void main(String[] args) 

{ 

Scanner sc=new Scanner(System.in);

System.out.println("enter n");

int n=sc.nextInt();

String a[]=new String[n];

System.out.println("enter "+n+" strings");

for(i=0;i<n;i++)

{ 

a[i]=sc.next();

} 

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

{ 

for(int j=i+1;j<n;j++)

{ 

if(a[i].compareTo(a[j])>0)
  { 

String t=a[i];

a[i]=a[j];

a[j]=t;

} 

} 

} 

for(i=0;i<n;i++)

{ 

System.out.print(Arrays.toString(a));

break;

} 

} 

}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter